Created
January 5, 2022 17:03
-
-
Save timebertt/3d82c1233b1ef1703ebd9a0748d276fd to your computer and use it in GitHub Desktop.
Updates and patches with controller-runtime clients
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ( | |
ctx context.Context | |
c client.Client | |
shoot *gardencorev1beta1.Shoot | |
) | |
// update | |
shoot.Spec.Kubernetes.Version = "1.22" | |
err := c.Update(ctx, shoot) | |
// json merge patch | |
patch := client.MergeFrom(shoot.DeepCopy()) | |
shoot.Spec.Kubernetes.Version = "1.22" | |
err = c.Patch(ctx, shoot, patch) | |
// strategic merge patch | |
patch = client.StrategicMergeFrom(shoot.DeepCopy()) | |
shoot.Spec.Kubernetes.Version = "1.22" | |
err = c.Patch(ctx, shoot, patch) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment