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

gconfig support env vars defined in a config.yaml #42

Merged
merged 3 commits into from
Mar 1, 2024

Conversation

drshriveer
Copy link
Owner

Background

→ I've been theorizing about supporting "templated" config values that might extract values from other parts of yaml or from environmental variables. This pr adds support for environmental variables.

Changes

  • Add support for env vars defined in yaml.
  • had to touch gerror to make test work.. that was a sad... really need to re-write gerror at this point.

Testing

  • updated tests for the feature.

@drshriveer drshriveer enabled auto-merge (squash) March 1, 2024 01:24
@drshriveer drshriveer merged commit bddbf02 into main Mar 1, 2024
3 checks passed
@drshriveer drshriveer deleted the gs/gconfig-support-env-vars branch March 1, 2024 01:26
@@ -23,7 +23,8 @@ go get -u github.com/drshriveer/gtools/gconfig
- **Dimensions:** A single configuration file may multiple "dimensions" that are resolved at runtime based on program flags to determine the variation of a setting to vend. Differentiating setting variables by environment/stage (e.g. Development, Beta, Prod) is a great example of how this can be leveraged.
- **Auto-flagging:** The configuration library will automatically turn dimensions into flags and parse them! (unless otherwise specified)
- **Env Parsing:** The configuration library will automatically parse dimensions environment variables.
- **GetDimension:** Extract a Dimension value via `gconfig.GetDimension[my.DimensionType](cfg)`.
- **GetDimension:** Extract a Dimension value via `gconfig.GetDimension[my.DimensionType](cfg)`.
- **Template Environmental Variables:** You can reference environmental variables in a config.yaml as values themselves! e.g. `var: ${{env: MY_ENV_VAR}}` will look up the variable `MY_ENV_VAR`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome!

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.

2 participants