Skip to content
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

Allow overwriting inline values with targetPath #1060

Merged

Conversation

Preisschild
Copy link
Contributor

@Preisschild Preisschild commented Sep 8, 2024

Fix: fluxcd/flux2#2330

When using Helm with both a values file and --set, the set will always have precedence over the values.yaml. This allows specifying the normal config inside a yaml file and specifying a secret outside that yaml via --set.

When using flux, this normally works too (using inline values to specify most of the config and a reference with targetPath to get a secret), but if you want to overwrite a secret key inside an array the inline values will always overwrite the whole array and the referenced secret key will not appear at all.

By making sure that when you specify a targetPath it has precedence over inline values it will be merged properly.

The Workaround mentioned in the original issue is limiting, because you can not easily use kustomize to overwrite certain keys in a configmap values.yaml stringBlock (for example in a multicluster setup with a common base), but you can do it with inline values.

@Preisschild Preisschild force-pushed the feat/targetpath-allow-overwrite branch 2 times, most recently from b8541c5 to 66893a7 Compare September 8, 2024 14:10
When using Helm with both a values file and --set, the set will always
have precedence over the values.yaml. This allows specifying the normal
config inside a yaml file and specifying a secret outside that yaml via
--set.

When using flux, this normally works too (using inline values to specify
most of the config and a reference with targetPath to get a secret), but
if you want to overwrite a secret key inside an array the inline values
will always overwrite the whole array and the referenced secret key will
not appear at all.

By making sure that when you specify a targetPath it has precedence over
inline values it will be merged properly.

Signed-off-by: Ströger Florian <[email protected]>
@Preisschild Preisschild force-pushed the feat/targetpath-allow-overwrite branch from 66893a7 to c07f108 Compare September 8, 2024 14:12
@Preisschild Preisschild changed the title Allow overwriting inline values with targetPathe Allow overwriting inline values with targetPath Sep 8, 2024
@Preisschild
Copy link
Contributor Author

Preisschild commented Sep 8, 2024

Here is the upstream helm code where they do this:

https://github.com/helm/helm/blob/main/pkg/cli/values/options.go#L44

They do --set things last, after --values.

After reading the flux documentation, I thought targetPath would behave similarly as helm --set, so i was confused by Flux' behaviour at first.

@stefanprodan stefanprodan added the area/helm Helm related issues and pull requests label Sep 13, 2024
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @Preisschild 🏅

@stefanprodan stefanprodan merged commit 94748ca into fluxcd:main Sep 13, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm Helm related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HelmRelease Values from targetPath array
3 participants