dynamicFields with / in key
Closed this issue · 2 comments
Hi,
I would like to use dynamicFields with kyes which has '/' characters.
Part of the templated yaml:
spec:
template:
metadata:
annotations:
checksum/values: 30da9af9da506b1fc3aa378d47e2d916f1d62e0e30dda84b25e855053233fd33
This is the .chartignore
dynamicFields:
- apiVersion: apps/v1
kind: Deployment
name: cosmo-auth-env
jsonPath:
- /spec/template/metadata/annotaions/checksum/values
I got the following error:
chart=. values=test/test.yaml err=failed to replace json path: failed to replace json path: failed to patch JSON6902: replace operation does not apply: doc is missing path: /spec/template/metadata/annotaions/checksum/values: missing value:
I tried the following escape segments:
/spec/template/metadata/annotaions/"checksum/values"
/spec/template/metadata/annotaions/'checksum/values'
/spec/template/metadata/annotaions/checksum%2Fvalues
None of the worked for me.
How can I escape the / in the key character?
Thank you for your help!
Hi @bendzsak-dpc Thank you for raising!
chartsnap use JSON Patch for dynamicField replacement and it comes from a famous Go library: https://github.com/evanphx/json-patch
In JSON Patch, escaping the /
character is documented in RFC6901, section 3
Because the characters '~' (%x7E) and '/' (%x2F) have special
meanings in JSON Pointer, '~' needs to be encoded as '~0' and '/'
needs to be encoded as '~1' when these characters appear in a
reference token.
So you need to specifiy the path which has /
like this:
/spec/template/metadata/annotaions/checksum~1values
Hi @jlandowner
Thank you for your help! I tried your suggestion and works like a charm.
It would be really helpful if you could add this to the documentation.
Anyway thank you again for your quick and helpful answer!