snyk-config

Crates.iosnyk-config
lib.rssnyk-config
version0.2.0
sourcesrc
created_at2019-11-10 22:14:56.06156
updated_at2023-10-06 09:22:46.717751
descriptionOpinionated JSON config loader
homepage
repositoryhttps://github.com/FauxFaux/snyk-config-rs
max_upload_size
id180111
size11,293
Chris West (FauxFaux)

documentation

README

snyk-config

This is a port of @snyk/config, an opinionated npm library which loads config from files and the environment.

It prefers:

  • environment variables, prefixed with CONF_, as literals or JSON
  • ${CONFIG_SECRET_FILE}
  • config.${SERVICE_ENV}.json
  • config.default.json

The ${env_vars} referenced above also have defaults:

  • CONFIG_SECRET_FILE defaults to ./config.secret.json
  • SERVICE_ENV defaults to local

Loaded values are merged, e.g.

config.default.json:

{"buy": {"potatoes": 5}}

config.secret.json:

{"buy": {"condamns": 1}}

env:

export CONF_buy__condamns=7
export CONF_debug=true

..will result in:

{"buy": {"condamns": 7, "potatoes": 5}, "debug": true}
Commit count: 2

cargo fmt