fsprojects / FSharp.Configuration

The FSharp.Configuration project contains type providers for the configuration of .NET projects.
http://fsprojects.github.io/FSharp.Configuration/
Other
114 stars 63 forks source link

Override YAML configs with ENV vars #168

Open tel opened 2 years ago

tel commented 2 years ago

Hi, I'd like to be able to declare overrides from environment variables in my YAML file. Generally, I'm interested in being able to set up an overrides file which inherits values from, say, a Kubernetes manifest declaring environment variables.

Ideally, the application would define a root config.yaml file which is loaded by the type provider and defines the configured values. Then, it would also include an override file which mirrors the structure of the inner config.yaml but declares environment variable overrides. The final values are then declared in a k8s manifest where they can inherit from k8s secrets and the like.

# /path/to/src/folder/config.yaml, included with the application code
Secrets:
  Provider:
    # documentation here describes the meaning and use of this key
    ApiKey: development_api_key
# /path/to/deploy/folder/local_config.yaml, available at the runtime location
Secrets:
  Provider:
    ApiKey: ${API_KEY}

This doesn't appear to work today as the YAML parsing does not interpolate env variables. I think the sufficient change would be to enable this functionality in YAML parsing.