Piny: envs interpolation for config files
Piny is YAML config loader with environment variables interpolation for Python.
Keep your app’s configuration in a YAML file.
Mark up sensitive data in config as environment variables.
Set environment variables on application deployment.
Let Piny load your configuration file and substitute environment variables with their values.
Piny is developed with Docker and Kubernetes in mind, though it’s not limited to any deployment system.
Simple example
Set your environment variables, mark up your configuration file with them:
db:
login: user
password: ${DB_PASSWORD}
mail:
login: user
password: ${MAIL_PASSWORD:-my_default_password}
sentry:
dsn: ${VAR_NOT_SET}
Then load your config with Piny:
from piny import YamlLoader
config = YamlLoader(path="config.yaml").load()
print(config)
# {'db': {'login': 'user', 'password': 'my_db_password'},
# 'mail': {'login': 'user', 'password': 'my_default_password'},
# 'sentry': {'dsn': None}}
CLI utility
Piny’s also got a command line tool working both with files and standard input and output:
$ export PASSWORD=mySecretPassword
$ echo "db: \${PASSWORD}" | piny
db: mySecretPassword
Rationale
Piny allows you to maintain healthy security/convenience balance when it comes to application’s configuration. Piny combines readability and versioning you get when using config files, and security that environment variables provide.
Read more about this approach in the blog post.
- Contributing to Piny
- Changelog
- v1.1.0 (2023-09-22)
- v1.0.2 (2023-02-03)
- v1.0.1 (2023-02-03)
- v1.0.0 (2023-01-02)
- v1.0.0rc1 (2023-01-01)
- v0.6.0 (2019-06-27)
- v0.5.2 (2019-06-17)
- v0.5.1 (2019-06-17)
- v0.5.0 (2019-06-17)
- v0.4.2 (2019-06-17)
- v0.4.1 (2019-06-17)
- v0.4.0 (2019-06-16)
- v0.3.1 (2019-06-09)
- v0.3.0 (2019-06-09)
- v0.2.0 (2019-06-09)
- v0.1.1 (2019-06-07)
- v0.1.0 (2019-06-07)
- v0.0.1 (2019-06-07)