Open ma-ble opened 9 months ago
This looks like a bug, thank you for reporting this @ma-ble. I will work out a fix for this
e:
upon looking at this again i think this is mostly a bug around formatting the multiple keys that are pulled from fieldpath into the tag injection, ill need to ask the cue community about this more
A workaround would be specifying multiple tags to inject each individual key
You should also not be specifying that this spec.test
would be converting to a string
within cue, i believe there is a way to have it convert into a cue object thats defined like
#input: {
key1: string
key2: string
karray: [...String]
key3: int
}
#env: #input @tag("test")
Im not certain if that works copy pasta'd
Thank you very much for the quick reply.
In my specific use case, I would like to copy all fields under spec.test into the managed resource. The number of fields is very large and I did not want to have any dependencies on individual fields in the composition in this case. This would only make it unnecessarily bloated and confusing.
Otherwise, you are of course right that you can simply list each individual field in the composition (CUEInport value) as a workaround.
I have created a new issue #82 that I think is a better solution to this problem. It seems problematic to have to try to convert nested fields into appropriate tag injections and the solution proposed in #82 I feel is a more crossplane native solution to this problem.
do you think this will work for you @ma-ble ?
In my opinion, the problems are slightly different, but essentially identical. In my case, I cannot outsource the data to an EnviornmentConfig, as this relates directly to a claim - but in both cases the processing of several fields via the cue functions is required.
I spoke with paul jolly at the cue project and we have figured out a way that we can do this with a single tag.
Since cue only allows for primitives to be injected, what we could do is take the field that is being injected, if it is an object (has nested fields), we can convert that object into a json strong. From there it will come in as json blob within cue, which the user can then from there the user can use cue's json.Marshal
. It is a bit cumbersome but it will give a single line entry for injecting + 1 more line for Marshaling
Great, do you have an example?
Unfortunately this repository is being deprecated and it is going to be merged with https://github.com/elastic/crossplane-function-cue, it is suggested that you move to this repository at your convenience. I have mentioned this functionality to paul before and perhaps we can bring this implementation over to the new repository as well
How can I inject several fields at once from the observed resource into the managed resource?
In my example, I would like to transfer everything under spec.test to the managed resource.
When executing - using the function-cue - I get the following resource.
How can I iterate over the string "test" in Cuelang so that I get the desired output?