Goal
I am trying to inject metadata into a kustomize build using the kustomize edit add annotation key:value command. I have several values, and would like to inject them into a single annotation field in JSON format, which is quite common for kubernetes (it also does this for kubectl.kubernetes.io/last-applied-configuration)
Problem
Reproduce by inserting json like so;
$ kustomize version
{Version:kustomize/v3.5.4 GitCommit:3af514fa9f85430f0c1557c4a0291e62112ab026 BuildDate:2020-01-11T03:12:59Z GoOs:linux GoArch:amd64}
$ touch kustomization.yaml
$ kustomize edit add annotation "test:{\"foo\":\"bar\",\"hello\":\"world\"}"
will cause Error: field: Invalid value: "\"hello\"": name part must consist of alphanumeric characters, [etc..]
I expect the same will happen with any string value containing a comma
Root cause
The current version does not accept more than one argument and as a consequence has to interpret arguments by comma separation.
Proposed solution
Let the shell handle argument separation, accepting each key-value pair as a single item in the argument list. No more need to split string by comma.
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
Could someone from the team please review this issue :) Maybe it could be clarified further..?
I had the same issue when setting annotation "helm.sh/hook":pre-install,pre-upgrade, it would become
commonAnnotations:
helm.sh/hook: pre-install
pre-upgrade: ""
Yes exactly, this confirms my "I expect the same will happen with any string value containing a comma"
An update on this would be nice :) I think it would improve the tool significantly.
You can declare a configMap as a workaround.
/assign
fixed in #3064
/close
@Shell32-Natsu: Closing this issue.
In response to this:
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Most helpful comment
I had the same issue when setting annotation
"helm.sh/hook":pre-install,pre-upgrade, it would become