-
Notifications
You must be signed in to change notification settings - Fork 137
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
Support default value for any
type
#883
Comments
I found the workaround for this. It was necessary to write the Starlark code, though.
#@data/values-schema
---
test:
#@schema/type any=True
optional_config: null
_default_optional_config:
param1: a
param2: b
#@ load("@ytt:data", "data")
#@ load("@ytt:struct", "struct")
#@ def combine_with_default(user_config, default_config):
#@ result = struct.decode(default_config)
#@ if user_config:
#@ result.update(struct.decode(user_config))
#@ end
#@ return result
#@ end
conf: #@ combine_with_default(data.values.test.optional_config, data.values._default_optional_config)
#@data/values
---
test:
optional_config:
param1: "aaa"
param3: "c"
parma4:
param4_4: "ddd" and here is the execution result: $ ytt -f schema.yaml -f template.yaml -f value.yaml
conf:
param1: aaa
param2: b
param3: c
parma4:
param4_4: ddd |
@LittleWat What you are trying to achieve can be easily done using an overlay
#@ load("@ytt:data", "data")
conf: #@ data.values.test.optional_config
#@data/values-schema
---
test:
#@schema/type any=True
optional_config:
param1: a
param2: b
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.all
---
conf:
#@overlay/match missing_ok=True
param3: c |
you can even overlay data values instead of overlaying final results using below variant of val.yml
#@ load("@ytt:overlay", "overlay")
#@data/values
#@overlay/match by=overlay.all
---
test:
optional_config:
#@overlay/match missing_ok=True
param3: c
|
Also feel free to use / explore carvel channel on kubernetes slack. A question similar to yours is here - https://kubernetes.slack.com/archives/CH8KCCKA5/p1675159628085549 |
@prembhaskal Hi, thank you for your quick replies! I see! |
hmm understood, so you want to hide the complexity of overlay from end user, but still allow them to pass in the extra configurations.
I can give it a try later today. |
Describe the problem/challenge you have
I want set the default value for
any
type but I can't.Here is the example.
Describe the solution you'd like
In the example, the expected output is:
I hope this is supported 🙏
Or I would be glad if you could share the workarounds for this 🙇♂️
Vote on this request
This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.
👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"
We are also happy to receive and review Pull Requests if you want to help working on this issue.
The text was updated successfully, but these errors were encountered: