Skip to content
New issue

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

Implement strategic merge patch #102

Open
vassilvk opened this issue Nov 6, 2022 · 0 comments
Open

Implement strategic merge patch #102

vassilvk opened this issue Nov 6, 2022 · 0 comments

Comments

@vassilvk
Copy link
Member

vassilvk commented Nov 6, 2022

Add merge op to the patch section of a ModRule.

This operation should trigger a Kubernetes strategic merge patch as implemented here: https://github.com/kubernetes/apimachinery/blob/master/pkg/util/strategicpatch/patch.go#L856.

The path expression of a merge patch operation determines the "original" JSON which is to be patched by the strategic merge.
The value of the patch is considered to be the "patch" JSON object passed to the strategic merge processing.

All the normal rules of select apply here - if select is present and it yields multiple results, then multiple merge operations will be performed, each time evaluating path and value in the context of the next selected item.

Example:

...
  patch:
    - op: merge
      select: '$.spec.template.spec.containers[? @.name == "my-container"]
      path: '/spec/template/spec/containers/#0/env'
      value: |-
        - name: ENV2
          value: true

The above patch will find container named my-container and it will inject environment variable ENV2 into it, without disturbing the remaining environment variables of the container.

This feature will solve #77 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant