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
Passing json objects/arrays as values through --set #10428
Comments
I think this would be possible. |
Thank you for your reply. |
@lucadirocco I think it's an interesting feature. The next step would be for someone who is interested in the feature to create a pull request and try to implement it. Anyone is welcome to do this. |
Hello @mattfarina , I have implemented this feature already last month, but I haven't issued a pull request due to lack of time and info about possible conditions/processes to be fulfilled/followed before issuing a pull request. Actually I was able to find the Contributing Guidelines: https://github.com/helm/helm/blob/main/CONTRIBUTING.md |
I am writing this pr, which can implement the json replacement for a key mentioned in the issues, but there are several problems here, and K8s has encountered similar problems. And according to the existing helm design, the actual effect is not to replace the value of entire key, but to cover the specific value. In addition, ambiguity arises when dealing with arrays: That is to say, the original values.yaml is as follows:
After "--set-json 'spec.sNssaiUpfInfoList[0]=[{"dnnUpfInfoList":[{"dnn":"intranet","ipv4AddressRanges":[{"end":"9.9.9.100"}]}]}]'" The result obtained is actually: (append to the array
or (replace the original array
but not (merge by
Because in fact, the values of helm do not have a design similar to patchStrategy, it is impossible to know whether the user wants to merge according to some item's trait in the array, or append the item into the array, or even replace all the elements of the array. |
@lucadirocco How did you solve the problem I mentioned above? thx |
@anurnomeru Later, we can see if it make sense to introduce more advanced mechanism to update the values through json on command line. |
When used with helm install, helm template, helm upgrade, it enables to set json values (scalars/objects/arrays) from the command line. Closess helm#10428
When used with helm install, helm template, helm upgrade, it enables to set json values (scalars/objects/arrays) from the command line. Closes helm#10428
When used with helm install, helm template, helm upgrade, it enables to set json values (scalars/objects/arrays) from the command line. Closes helm#10428 Signed-off-by: Luca Di Rocco <lucadirocco@gmail.com>
When used with helm install, helm template, helm upgrade, it enables to set json values (scalars/objects/arrays) from the command line. Closes helm#10428 Signed-off-by: Luca Di Rocco <lucadirocco@gmail.com>
When used with helm install, helm template, helm upgrade, it enables to set json values (scalars/objects/arrays) from the command line. Closes helm#10428 Signed-off-by: Luca Di Rocco <lucadirocco@gmail.com>
Hello @mattfarina, I have issued a pull request #10693 for this issue, which has also got a review (LGTM) by joejulian, who however said he is not an approver. |
Would it also be nice if |
feat: add --set-json flag to set json values This feature available in which release?. |
When used with helm install, helm template, helm upgrade, it enables to set json values (scalars/objects/arrays) from the command line. Closes helm#10428 Signed-off-by: Luca Di Rocco <lucadirocco@gmail.com>
I would like to set json objects/arrays as values through --set.
According to https://helm.sh/docs/intro/using_helm/#the-format-and-limitations-of---set
currently that is not possible (with the exception of arrays of scalar types)
As example, let's take the following excerpt from my values.yaml file:
In the template there is all the "range" based logic for slices and maps, to correctly render sNssaiUpfInfoList from .Values.spec.sNssaiUpfInfoList, so further elements could be added to each of the above arrays and they would appear in the final manifest generated by helm.
In order to set sNssaiUpfInfoList above, currently I have to set the individual leaf attributes of the data structure, by providing the following with --set on command line:
'spec.sNssaiUpfInfoList[0].sNssai.sd=0002f0,spec.sNssaiUpfInfoList[0].sNssai.sst=1,spec.sNssaiUpfInfoList[0].dnnUpfInfoList[0].dnn=intranet, spec.sNssaiUpfInfoList[0].dnnUpfInfoList[0].ipv4AddressRanges[0].end=9.9.9.94, spec.sNssaiUpfInfoList[0].dnnUpfInfoList[0].ipv4AddressRanges[0].start=9.9.9.65'
This is not very flexible because extra logic is required to translate the data structure into individual key=val for each of its leaf attributes. Moreover, the arrays are dynamic, and quite a long list of key=val could be generated.
I think it would be much simpler if we had an option to set a complete json array/object on the command line.
For example, to set sNssaiUpfInfoList above, we could use something like:
--set-json 'spec.sNssaiUpfInfoList=[{"sNssai":{"sd":"0002f0","sst":1},"dnnUpfInfoList":[{"dnn":"intranet","ipv4AddressRanges":[{"end":"9.9.9.94","start":"9.9.9.65"}]}]}]'
Is it possible to add this option to helm?
The text was updated successfully, but these errors were encountered: