Adding elements to list that is not empty #3800
-
Is your feature request related to a problem? Please describe. I'm always frustrated when i have a json array that should be filled but has some predefined values. e.g. this wont work and gives the error:
Describe the solution you'd like I'd like to add predefined values to a list like in the code above. Describe alternatives you've considered For simple types like string, an intermediate list can be created with the predefined values in it, and using the parameters. Then flatten it as input. I don't know if this migt work for more complex structs. Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
As hinted by the official implementation, this can be done by using I've tested with the following code snippet, if parameter["env"] == _|_ {
env: predefinedEnv
}
if parameter["env"] != _|_ {
env: predefinedEnv + parameter.env
} |
Beta Was this translation helpful? Give feedback.
-
Thanks! I think this should be the right answer. Closing, @siredmar feel free to re-open it if the issue still exists. |
Beta Was this translation helpful? Give feedback.
As hinted by the official implementation, this can be done by using
+
operator.https://github.com/oam-dev/kubevela/blob/master/vela-templates/definitions/internal/trait/env.cue#L44-L59
I've tested with the following code snippet,