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

Run ENV Substitution if empty substituted #388

Closed
oliverbaehler opened this issue Jul 6, 2021 · 3 comments · Fixed by #389
Closed

Run ENV Substitution if empty substituted #388

oliverbaehler opened this issue Jul 6, 2021 · 3 comments · Fixed by #389

Comments

@oliverbaehler
Copy link
Contributor

Hi

I was playing around with variable substitutions. I made heavy use of defaulting mechanisms. Till I noticed, that defaults are not evaluated, when the owning Kustomization does not have any variables substituted. In fact no expression is evaluated. Looking at the code, this condition causes this:

I am not quiet sure if this is on purpose but the expected behavior for me would be if i have a default expression, it should default if the variable isn't set. But before trying to change the code I wanted to check with you guys, what you think about it.

@stefanprodan
Copy link
Member

stefanprodan commented Jul 6, 2021

We can't enable var substitution by default, it needs to be opt-in (defined now as having at least one var). The reason for this is that envsub replaces all vars without a default with string empty and it has the potential to break scripts embedded in configmap and other objects.

@oliverbaehler
Copy link
Contributor Author

Yeah i get that point, but shouldn't such resources, which might have such expressions in them disabled substitution (aka kustomize.toolkit.fluxcd.io/substitute: disabled). So I guess the way to work around this, is having something like this:

apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
  name: shared
spec:
  ...
  postBuild:
    substitute:
      enabled: "true"

I guess that works for me, if there's no interest in this change.

@stefanprodan
Copy link
Member

@oliverbaehler I would welcome a PR to the docs here that explains the current behaviour with your example on how to enable substitutions for default values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants