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

feat: Add support for using env vars in config #10

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

qwertzlbert
Copy link
Contributor

PR(Pull Request) Overview

This change allows users to add tags to the configuration file which can be replaced via environment variables.
This can be useful in cases were access tokens should be injected into the config, but should not be directly
stored in the config file.

Changes

  • Major feature addition or modification
  • Bug fix
  • Code improvement
  • Documentation update

Description of Changes

This change invokes a search and replace routine before the loaded config is unmarshaled by the yaml parser.
The function searches for all entries matching the regex (${...}) and tries to load an environment variable
of the same name. If nothing is found nothing will be replaced.

Testing Method

I added a small unit test to config_test.go

Additional Information

I was considering using the text/template package instead, but decided otherwise as I wanted to keep the
functionality at a minimum and not add additional support for more templating.

@Jeongseup
Copy link
Member

Thank you for a lot of contributions. your work is REALLY thankful and meaningful for making stable blockchain nodes for validators! I'm sorry to say that I'll go to personal trip to take a rest after launching this service. And so, I'll review and merge your PR after the trip. Please wait some time.

@qwertzlbert
Copy link
Contributor Author

Thank you for your feedback and starting this project in the first place!
No worries I understand, we can review my PRs when you are back. I'll just continue development on my fork and open PRs with cherry-picks of changes I added.
For now stay safe and have a nice trip!

@Jeongseup
Copy link
Member

I need more time to consider this PR. Thanks

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