We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently, strategic merge patches can be sent using client.RawPatch like this:
client.RawPatch
var deploy *appsv1.Deployment deployCopy := deploy.DeepCopy() // do changes i, container := findContainerByName(deployCopy.Spec.Template.Spec.Containers, "nginx") container.Image = "nginx:updated" deployCopy.Spec.Template.Spec.Containers[i] = container // calculate patch oldDeployJSON, _ := json.Marshal(deployCopy) deployJSON, _ := json.Marshal(deploy) patchBytes, _ := strategicpatch.CreateTwoWayMergePatch(oldDeployJSON, deployJSON, &appsv1.Deployment{}) // send patch return c.Patch(ctx, deploy, client.RawPatch(types.StrategicMergePatchType, patchBytes))
This will sent a patch looking like this, which will leverage the API's mergeKey:
mergeKey
{"spec":{"template":{"spec":{"$setElementOrder/containers":[{"name":"nginx"},{"name":"sidecar"}],"containers":[{"image":"nginx:some-version","name":"nginx"}]}}}}
It would be nice to support creating such strategic merge patch similar to client.MergeFrom (which will create a json merge patch), like this:
client.MergeFrom
// do changes i, container := findContainerByName(deployCopy.Spec.Template.Spec.Containers, "nginx") container.Image = "nginx:updated" deployCopy.Spec.Template.Spec.Containers[i] = container // send patch return c.Patch(ctx, deploy, client.StrategicMergeFrom(deployCopy))
The text was updated successfully, but these errors were encountered:
/assign
Sorry, something went wrong.
timebertt
Successfully merging a pull request may close this issue.
Currently, strategic merge patches can be sent using
client.RawPatch
like this:This will sent a patch looking like this, which will leverage the API's
mergeKey
:It would be nice to support creating such strategic merge patch similar to
client.MergeFrom
(which will create a json merge patch), like this:The text was updated successfully, but these errors were encountered: