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

[FLI-907] config: add ability to specify env vars #2844

Open
1 task done
markphelps opened this issue Mar 12, 2024 · 1 comment
Open
1 task done

[FLI-907] config: add ability to specify env vars #2844

markphelps opened this issue Mar 12, 2024 · 1 comment
Labels
enhancement Created by Linear-GitHub Sync go good first issue help wanted Halp md Not too big, not too small

Comments

@markphelps
Copy link
Collaborator

markphelps commented Mar 12, 2024

Problem

Currently, Flipt supports configuration via YAML or ENV vars (https://www.flipt.io/docs/configuration/overview). Environment variables override config files. Env var keys that Flipt supports comes directly from the keys of the YAML config.

What we don't currently allow is specifying env vars in the conf file format.

Why this could be a problem is the env var keys become exceptionally long depending on how deeply nested the corresponding YAML config is. Example:
authentication.methods.oidc.providers.github.client_id in YAML becomes FLIPT_AUTHENTICATION_METHODS_OIDC_PROVIDERS_GITHUB_CLIENT_ID as an env var.

Ideal Solution

It would be nice if we could provide a 'shortcut' for specifying configuration in YAML that would allow users to specify env var keys that we should look in for the correct value.

Ie: "${env:FLIPT_GITHUB_CLIENT_ID}"

This would allow users to swap in whatever env var keys they want and we could look for those values at startup, failing fast if we cant find the env var value.

Search

  • I searched for other open and closed issues before opening this

Additional Context

Since we use Viper for config parsing, I think we could use some of the tactics described in this blog post: https://sagikazarmark.hu/blog/decoding-custom-formats-with-viper/ to decode a value that follows with the above format ${env:value}

FLI-907

@markphelps markphelps added the enhancement Created by Linear-GitHub Sync label Mar 12, 2024
@markphelps markphelps changed the title config: add ability to specify env vars [FLI-907] config: add ability to specify env vars Mar 12, 2024
@GeorgeMac
Copy link
Contributor

💯 we already extensively used custom decoder hooks. So it could be added here:

var DecodeHooks = []mapstructure.DecodeHookFunc{
mapstructure.StringToTimeDurationHookFunc(),
stringToSliceHookFunc(),
stringToEnumHookFunc(stringToLogEncoding),
stringToEnumHookFunc(stringToCacheBackend),
stringToEnumHookFunc(stringToTracingExporter),
stringToEnumHookFunc(stringToScheme),
stringToEnumHookFunc(stringToDatabaseProtocol),
stringToEnumHookFunc(stringToAuthMethod),
}

It could likely be implemented as one that maps from string to string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Created by Linear-GitHub Sync go good first issue help wanted Halp md Not too big, not too small
Projects
Status: No status
Development

No branches or pull requests

2 participants