-
Hi I'm trying to get sense of nickel and also CUE while model some IaC composition. I'm really noob in this. I'd like to model a record where
have sense what i'm looking for? or maybe I need to model data different? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Well, I've found a not scalable solution, but at least i'm starting to understand.
|
Beta Was this translation helpful? Give feedback.
-
Hi! I think this is related to #459. Indeed CUE does have a specific constructs to conditionally define part of contract depending on other fields. It's not totally obvious how to implement this for Nickel, so for now, we don't have that yet. I think your approach is actually not that bad 🙂 since you can write arbitrary expressions for contract, if you'd like, you can actually inline the condition, which in the end kinda resembles the if construct of CUE:
It's maybe not totally satisfying, but at least the logic is right inside the contract. Another slight variation is to define a function for that:
You can use a switch if you have more than one condition:
There are a few quirks, like if you want |
Beta Was this translation helpful? Give feedback.
Hi!
I think this is related to #459. Indeed CUE does have a specific constructs to conditionally define part of contract depending on other fields. It's not totally obvious how to implement this for Nickel, so for now, we don't have that yet.
I think your approach is actually not that bad 🙂 since you can write arbitrary expressions for contract, if you'd like, you can actually inline the condition, which in the end kinda resembles the if construct of CUE:
It's maybe not totally satisfying, but at…