shuttle icon indicating copy to clipboard operation
shuttle copied to clipboard

feat: Add support to parse a SecretStore as a struct using the config crate

Open JasterV opened this issue 1 year ago • 3 comments

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 avatar Mar 05 '24 17:03 JasterV

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 avatar Mar 05 '24 18:03 JasterV

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

JasterV avatar Mar 05 '24 18:03 JasterV

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.

jonaro00 avatar Mar 11 '24 10:03 jonaro00