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 to parse a SecretStore as a struct using the config crate #1666

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

Conversation

JasterV
Copy link
Contributor

@JasterV JasterV commented Mar 5, 2024

Description of change

The config crate is pretty standard nowadays on the Rust community to parse configuration files to a Rust type.
I didn't want to fetch one by one the secrets from the SecretStore manually since the config crate does that automatically and I figured out a way to pass the contents of the SecretStore as an Environment source to the ConfigBuilder as explained here.

How has this been tested? (if applicable)

I use this implementation locally on my production software.

@JasterV JasterV force-pushed the feat/config-crate-support-for-secrets branch from 531675d to efb579b Compare March 5, 2024 18:24
@JasterV JasterV force-pushed the feat/config-crate-support-for-secrets branch from efb579b to 59ebf90 Compare March 5, 2024 18:25
@JasterV
Copy link
Contributor Author

JasterV commented Mar 5, 2024

I wanted to implement the From crate for any T that implement DeserializeOwned but Rust doesn't allow to implement a foreign trait to a foreign type so I guess I should create some sort of wrapper around T

@JasterV
Copy link
Contributor Author

JasterV commented Mar 5, 2024

Probably a proper thing to do could be to implement Deserialize on the SecretsStore to a NewType SecretsConfig that contains T

@jonaro00
Copy link
Member

Thanks for the suggestion! We will consider adding support for more opinionated ways of secrets/env loading like this one in a future update. In that case it can probably be built in without a feature flag. Will leave this PR open to keep the idea alive. More discussions can be found in #1571.

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.

None yet

2 participants