-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: per-chart helm configuration #310
Conversation
Hi @Zebradil , while testing this, I conceived an app-data.ytt.yaml that would currently fail:
It would lead to the following error:
Is this a case you have considered? |
Hi @fritzduchardt, thanks for testing! It is a bug, and a new test case. I'll implement it shortly. |
@fritzduchardt it turns out that it's not a bug, but a limitation of ytt. You can't define default values for arrays like that in a ytt schema file ( #@ def charts():
- name: render-test-1
releaseName: overriden-release-name-1
- name: render-test-2
releaseName: overriden-release-name-2
#@ end
#@data/values-schema
---
helm:
#@schema/default charts()
#@overlay/replace
#@schema/validation ("chart names must be unique", lambda x: len(set([c["name"] for c in x])) == len(x))
charts:
- buildDependencies: false
includeCRDs: false
#@schema/validation min_len=1
name: ""
namespace: ""
releaseName: "" The latter I find very inconvenient, because you have to copy the original array item definition, as well as the validation annotations. |
Nice workaround! Since you also do validation in config_helm.go, I guess the validations are not strictly required. |
} | ||
|
||
chartConfigs := map[string]HelmChartOverride{} | ||
for i, chart := range helmConfigWrapper.Helm.Charts { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also validate for charts being part of the config, but not of the actual app. Of course, this would lead to a lot of errors/warnings, if you define your chart-specific configuration in the env-data.ytt.yaml. Nevertheless, this feature seems more likely to be used in the app-data.ytt.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an interesting idea. I think we can give it a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented. This is how it looks like.
Currently, there is no central place for config validation (and it will require significant changes to the overall program structure to implement it), this is why it is duplicated in the sync
and render
steps and printed twice. But I think we can live with that :-)
Later, if these warnings are too annoying, we can add a switch to disable it.
examples/integration-tests/prototypes/per-chart-override/app-data.ytt.yaml
Outdated
Show resolved
Hide resolved
That's right. However, ytt validations give better error message, in my opinion. But of course, it is completely up to the user :-) |
This PR adds per-chart Helm configuration, resolving #261.
There is a new
helm.charts
subsection in the configuration schema:It's a list of per-chart overrides of the common options under the
helm
key in the config.Selecting the chart-specific configuration is done via matching the
name
field with the chart's base name. For example, if a chart's path defined in the vendir config ischarts/CHART_NAME
, thenCHART_NAME
is the name of the chart and is used for selecting the options overrides.