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

fix(config): Restore old environment var behavior with option #13457

Merged
merged 9 commits into from
Jun 21, 2023

Conversation

srebhan
Copy link
Contributor

@srebhan srebhan commented Jun 16, 2023

resolves #13456
resolves #13432
resolves #13455
resolves #13460

After a lot of back-and-forth this PR restores the old environment-variable behavior using the --old-env-behavior command line option. That is, all $VAR and ${VAR} environment variables are replaced if and only if they do exist, otherwise those patterns are left untouched. Furthermore, double dollar signs $$ do not have any meaning so $$VAR becomes $foobar if VAR="foobar" in the environment.

If the new behavior is enabled (default), the only difference is that $$ will escape the expression, i.e. $$VAR will become $VAR even if VAR is defined in the environment...

Here an exemplary overview of the behavior with VAR="foo" and FALLBACK="bar" defined in the environemt:

input result with --old-env-behavior result without --old-env-behavior identical
$VAR foo foo ✔️
$$VAR $foo $VAR ✖️
\$VAR \foo \foo ✔️
${VAR} foo foo ✔️
$${VAR} $foo ${VAR} ✖️
\${VAR} \foo \foo ✔️
\$${VAR} \$foo \${VAR} ✖️
$FOO $FOO $FOO ✔️
${FOO} ${FOO} ${FOO} ✔️
$${FOO} $${FOO} ${FOO} ✖️
${FOO:-${FALLBACK}} bar bar ✔️
${FOO:-FALLBACK} FALLBACK FALLBACK ✔️

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Jun 16, 2023
@srebhan
Copy link
Contributor Author

srebhan commented Jun 16, 2023

Please note that the replacement in go.mod can be removed as-soon-as compose-spec/compose-go#418 is merged.

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jun 16, 2023
@telegraf-tiger
Copy link
Contributor

@powersj powersj merged commit 47e10e1 into influxdata:master Jun 21, 2023
24 checks passed
powersj pushed a commit that referenced this pull request Jun 21, 2023
@srebhan srebhan added this to the v1.27.1 milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
2 participants