Manipulating map keys on arrays #529
-
I have tried quite a few different approaches here, but struggling to get to the final solution. Basically I have a list of URIs I want to use as the main values to transform different keys and values, depending on where. values.yaml
The intended target yaml is:
Here is what I'm currently trying template.yaml
Result
Trying a for loop straight from loaded data:
Result:
Closest I got, but it wraps in single quotes:
Result:
Also tried
but can't make it work with the values. Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
Hey @mtrin-wooliesx. Thanks for posting your question. I believe you're looking to do something like this: https://carvel.dev/ytt/#gist:https://gist.github.com/pivotaljohn/d095513775852285015f1e1a45b807f7 Getting there took a key insight: Is that solution I linked to going in the direction you were hoping? Looking down the road, I suspect you have four variables: the route, the metric, the metric template, and the route+metric params. Extracting these into variables and then composing the template output through a small set of functions can keep the overall template versatile/flexible. . We can certainly continue our conversation here. If you'd prefer, you can also get timely help in our channel on the Kubernetes Slack: #carvel. If you are not already in that Slack workspace, you can sign up here: https://slack.k8s.io/. Cheers! |
Beta Was this translation helpful? Give feedback.
-
Amazing! Thank you so much for this. It really helped me understand more on how feature rich this is. Last question, if I wanted to build a schema.yaml, how would that work? It doesn't seem to like the fact we have a key as a variable? Again, thank you so much. |
Beta Was this translation helpful? Give feedback.
-
Woohoo!
Hmmm. I'm not sure what you're referring to. Can you give an example of what you're attempting? I was able to take that last Playground link and change "@data/values" to "@data/values-schema" and it just worked, for me. |
Beta Was this translation helpful? Give feedback.
-
Hello @pivotaljohn sorry for the late followup https://carvel.dev/ytt/#gist:https://gist.github.com/mtrin-wooliesx/6eb6678a8106c1140c3f4c0c3915c453 I have tried quite a few different things, but here is where I'm at. all the best |
Beta Was this translation helpful? Give feedback.
-
Just for reference, this is what ended up working for me 🙂
|
Beta Was this translation helpful? Give feedback.
Just for reference, this is what ended up working for me 🙂
thanks for the community!