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 escaping $ in config files that use expand env #5576

Merged
merged 10 commits into from
Oct 17, 2024

Conversation

kfox1111
Copy link
Contributor

Fixes #5574.

$$ will match an env var named '$' which resolves to '$', allowing passing through '$'s.

Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
@azdagron azdagron self-assigned this Oct 15, 2024
Copy link
Member

@azdagron azdagron left a comment

Choose a reason for hiding this comment

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

SPIRE for better or worse accommodates a bring-your-own-main approach so main isn't quite the right place for this. Further, we can leverage the [os.Expand] function instead of os.ExpandEnv to avoid having to set/unset an environment variable.

I'd suggest adding a function in pkg/common/config or something called ExpandEnv that:

  1. Called os.Getenv to gather the current environment
  2. Added the '$' entry
  3. called os.Expand

This function could then be called in place of os.ExpandEnv in the agent/server run packages.

Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Copy link
Member

@azdagron azdagron left a comment

Choose a reason for hiding this comment

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

Thanks, @kfox1111 !

@azdagron azdagron added this to the 1.11.0 milestone Oct 17, 2024
@MarcosDY MarcosDY merged commit 2d784fc into spiffe:main Oct 17, 2024
34 checks passed
@kfox1111 kfox1111 deleted the expand-escape branch October 17, 2024 21:41
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 this pull request may close these issues.

[spire-server] go template variable issue
3 participants