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

Expose env variables in the context in a controllable way #202

Closed
traut opened this issue Jun 14, 2024 · 0 comments · Fixed by #205
Closed

Expose env variables in the context in a controllable way #202

traut opened this issue Jun 14, 2024 · 0 comments · Fixed by #205
Assignees
Labels
Milestone

Comments

@traut
Copy link
Member

traut commented Jun 14, 2024

Background

It is already possible to use the values of environment variables through env var in HCL. This has a limited use, though, since env var values exist outside the evaluation context and can not be easily filtered/mutated.

Design

Env variables should be available in the evaluation context under .env root key.

To minimize the risk of exposing all environment variables to potentially malicious plugins, we introduce a global configuration argument expose_env_vars_with_prefix.

If expose_env_vars_with_prefix is set, only the env vars that have the prefix in their name are available in the context under .env key.

If expose_env_vars_with_prefix is null, use the default value.
If expose_env_vars_with_prefix is an empty string, all env variables are exposed in the context

Example:

fabric {
    expose_env_vars_with_prefix = "FABRIC_"  # default value
}

document "test" {
  content text {
    value = "All env vars in the context: {{ .env | toPrettyJson }}" 
  }
}
@traut traut added the fcl label Jun 14, 2024
@traut traut added this to the v0.4 milestone Jun 14, 2024
@Andrew-Morozko Andrew-Morozko self-assigned this Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants