You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
value interpreted as int when intended as string #1694
Consider a CI pipeline that hands a commit sha between jobs for the purpose of identifying artifacts named with said sha (usually the "short" version as one might get from git rev-parse --short HEAD).
If said short sha happens to feature only numeric characters, for example, 1194495, and one attempts to set a corresponding value in a chart that consumes this, say via helm install chart --set short_sha=1194495, although helm get values appears to show it as a string, it actually exists in the pod's/underlying container's environment as 1.194495e+06 (meaning, it has understandably been cast to type int.)
Quoting the value on --set doesn't appear to help (helm install chart --set short_sha="1194495") which makes sense as there doesn't appear to be support in the parser for this yet; so the value from helm get values is still unquoted.
(Setting the value directly in the values.yaml file, quoted, does have the desired effect of maintaining the value's... string-ness.)
tl;dr So, I suppose my question is, how/where might one mandate type for a value sent in via --set, using the example provided above as a use case? (Or, can/should this be done in the chart itself when it consumes the value?)
Reacted by 蔡仲明 (Romulus Urakagi Tsai), Yang Hanlin, jbrardport, Coffee Boy and Alyssa Holland
Of possible interest, while helm get values displays cli_version: 1194495 via the --set scenario above, when the same is set in a values.yaml file used on install, helm get values more transparently shows how the value has been interpreted as an int (again, understandably):
@technosophos Thank you for the creative workaround suggestion! I've tried many variations of it but unfortunately, either my bash terminal interprets the un-escaped !! pair as 'run the last command again' or, if I escape these special characters, the value that ends up in the configmap is a literal myval: '!!string 1234' (And that full literal !!string 1234 val is sent down to the container.)
Do you think it would be encouraged to implement support for parsing quotes such that --set myval='1234' or --set myval="1234" would make sure myval: "1234" results? (Meaning, quoting mandates type string) I'm definitely game to give it a go if so...
@longseespace Thank you very much for sending your approach! At first I was mystified by why it wouldn't work for me:
$ helm install workflow-e2e --namespace deis --set cli_version=\"1194495\"
Error: YAML parse error on workflow-e2e/templates/workflow-e2e-pod.yaml: error converting YAML to JSON: yaml: line 18: did not find expected key
Then I remembered to check on how said value is used in the manifest template:
Sure enough, when I remove the surrounding quotes from the {{.Values.cli_version}}, and try the approach presented, it works (the value is a string).
I guess I'm still wondering why, when setting cli_version=1234, the 1234 value isn't quoted when the manifest is generated (using quoted form above)? Is that where a bug might be? Perhaps the parser is "interfering" when it should not be?
I think a fix for #1707 would actually resolve this issue.
(Again note, as mentioned above, that using --set val=\"1234\" does not seem to be compatible if val is quoted in manifest template as "{{.Values.val}}")
Reacted by Glenn Morton, Sagar Kalburgi and Yang Hanlin
For people who came here because they have the issue, you can now use the --set-string argument
Reacted by Akito, Adam Vollrath, emmanuelsosa, Kristo, Roman Mitasov, Derek.Chia, MAUGIN Thomas, Yurii Komar, Dima Diachenko, Andreas Salhus Bakseter and 2 more
Activity
vdice commentedon Dec 16, 2016
Perhaps it would help to give a concrete example, with output edited to focus on issue.
Here using the deis/workflow-e2e chart (with relevant use of the following
cli_versionvalue in pod's template here):(yup, two
reelings in a row! 😳 )vdice commentedon Dec 16, 2016
Of possible interest, while
helm get valuesdisplayscli_version: 1194495via the--setscenario above, when the same is set in avalues.yamlfile used on install,helm get valuesmore transparently shows how the value has been interpreted as an int (again, understandably):Which is to say, there may be another/separate minor issue on displaying the 'true' value used back to the user on
helm get valueswhen--setis used.technosophos commentedon Dec 16, 2016
I beleive that the real cheater-chearter way to do this is to specify type directly. In YAML, you use type tags (
!!stringor!!int).I think you can pass this in set:
--set "myval=!!string 1234". But I might be wrong. I've never tried.vdice commentedon Dec 16, 2016
@technosophos Thank you for the creative workaround suggestion! I've tried many variations of it but unfortunately, either my
bashterminal interprets the un-escaped!!pair as 'run the last command again' or, if I escape these special characters, the value that ends up in the configmap is a literalmyval: '!!string 1234'(And that full literal!!string 1234val is sent down to the container.)Attempts included:
Do you think it would be encouraged to implement support for parsing quotes such that
--set myval='1234'or--set myval="1234"would make suremyval: "1234"results? (Meaning, quoting mandates type string) I'm definitely game to give it a go if so...longseespace commentedon Dec 17, 2016
@vdice This issue has been bugging me for a few days now. I ended up escaping the quote like this:
--set myval=\"1234\". Hope this could help youvdice commentedon Dec 17, 2016
@longseespace Thank you very much for sending your approach! At first I was mystified by why it wouldn't work for me:
Then I remembered to check on how said value is used in the manifest template:
Sure enough, when I remove the surrounding quotes from the
{{.Values.cli_version}}, and try the approach presented, it works (the value is a string).I guess I'm still wondering why, when setting
cli_version=1234, the1234value isn't quoted when the manifest is generated (using quoted form above)? Is that where a bug might be? Perhaps the parser is "interfering" when it should not be?longseespace commentedon Dec 17, 2016
@vdice Which helm version are you using? I can't seem to reproduce. I'm using latest helm (v2.1.0) and it's working fine for me
vdice commentedon Dec 19, 2016
@longseespace interesting -- I'm on 2.1.0 as well, though noticing the tiller version commit differs; will try to align and test...
update: versions aligned; same behavior as mentioned in #1694 (comment)
vdice commentedon Dec 19, 2016
I think a fix for #1707 would actually resolve this issue.
(Again note, as mentioned above, that using
--set val=\"1234\"does not seem to be compatible if val is quoted in manifest template as"{{.Values.val}}")technosophos commentedon Feb 15, 2017
I'm going to close this as a duplicate of #1707, since fixing one will fix both.
control-service: fix helm image tag type
control-service: fix helm image tag type (#661)
CharlesB2 commentedon Sep 15, 2023
For people who came here because they have the issue, you can now use the
--set-stringargumentFix incorrect chart bug in multi-cluster setup (helm#1698)