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

JSONPatch annotations containing slashes #1256

Closed
benjamin-bergia opened this issue Jun 26, 2019 · 6 comments
Closed

JSONPatch annotations containing slashes #1256

benjamin-bergia opened this issue Jun 26, 2019 · 6 comments

Comments

@benjamin-bergia
Copy link

Not really a Kustomize issue but we definitely need a work around.

When patching annotations, it happens that the keys contain /. Like for example when patching my ingress:

- op: add
  path: /metadata/annotations/traefik.ingress.kubernetes.io/redirect-permanent
  value: false

This doesn't work since it should be interpreted as

metadata:
  annotations:
    traefik.ingress.kubernetes.io/redirect-permanent: false

But is actually interpreted as:

metadata:
  annotations:
    traefik.ingress.kubernetes.io:
      redirect-permanent: false
@dbarrosop
Copy link

dbarrosop commented Sep 25, 2019

Is there an actual solution for this? I am having the same problem

@benjamin-bergia
Copy link
Author

Yep, it's part of jsonpatch http://jsonpatch.com/#json-pointer

@tkellen
Copy link
Contributor

tkellen commented Sep 25, 2019

Just to put the solution right here directly, use ~1 to represent a /

@RobertDiPaolo
Copy link

RobertDiPaolo commented Dec 6, 2019

It also seems that you need to quote the path if you use the ~1 escape, e.g.

- op: add
  path: "/metadata/annotations/traefik.ingress.kubernetes.io~1redirect-permanent"
  value: false

@John-Lin
Copy link

John-Lin commented Nov 6, 2020

how come the docs describe that put a \ before /?

Kustomize supports escaping special characters in path, e.g metadata/annotations/foo.k8s.io/bar
https://github.com/kubernetes-sigs/kustomize/tree/master/examples/transformerconfigs#supporting-escape-characters-in-crd-path

see #907

@Shell32-Natsu
Copy link
Contributor

@John-Lin JSON patch itself has its own definition and implementation. It's irrelevant from how kustomize handle the slash.

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

6 participants