Kustomize: error when kustomize build : support for escape special characters in path for a patch json6902

Created on 9 Mar 2020  路  7Comments  路  Source: kubernetes-sigs/kustomize

hi there,

noticed that kustomize 3.5.4 is not able to escape special characters.

patch.yaml


- op: replace
  path: /metadata/annotations/cnrm.cloud.google.com\/project-id
  value: dummy-2

Resource file


apiVersion: v1
kind: Namespace
metadata:
  annotations:
    cnrm.cloud.google.com/project-id: dummy
  name: some-ns

It gives an error:


Error: failed to apply json patch '[{"op":"replace","path":"/metadata/annotations/cnrm.cloud.google.com\\/project-id","value":"dummy-2"}]': replace operation does not apply: doc is missing path: /metadata/annotations/cnrm.cloud.google.com\/project-id: missing value

https://github.com/kubernetes-sigs/kustomize/issues/907

https://github.com/kubernetes-sigs/kustomize/tree/master/examples/transformerconfigs#supporting-escape-characters-in-crd-path

kinbug

All 7 comments

I would like to take this.
/assign

I'm running into this issue on version 3.5.4.

Same here. @vanou ping if I should build a fix.

I was able to get this working by using ~1.

If you need to refer to a key with ~ or / in its name, you must escape the characters with \~0 and \~1 respectively. For example, to get "baz" from { "foo/bar~": "baz" } you鈥檇 use the pointer /foo\~1bar~0.

http://jsonpatch.com/

Sorry. Currently I have limited resource to work on this. However I'll work on this.
Thank you.

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

/remove-lifecycle stale

Was this page helpful?
0 / 5 - 0 ratings