Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drkostas/yaml-config-wrapper
A YAML configuration wrapper.
https://github.com/drkostas/yaml-config-wrapper
config-management configuration configuration-management yaml yaml-configuration yml yml-configuration
Last synced: 3 months ago
JSON representation
A YAML configuration wrapper.
- Host: GitHub
- URL: https://github.com/drkostas/yaml-config-wrapper
- Owner: drkostas
- License: apache-2.0
- Created: 2021-12-10T01:54:15.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-30T01:42:19.000Z (about 3 years ago)
- Last Synced: 2024-10-12T08:08:01.161Z (4 months ago)
- Topics: config-management, configuration, configuration-management, yaml, yaml-configuration, yml, yml-configuration
- Language: Python
- Homepage: https://pypi.org/project/yaml-config-wrapper/
- Size: 99.6 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# YAML Config Wrapper
[![Downloads](https://static.pepy.tech/personalized-badge/yaml-config-wrapper?period=total&units=international_system&left_color=grey&right_color=red&left_text=Downloads)](https://pepy.tech/project/yaml-config-wrapper)
[![GitHub license](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/drkostas/yaml-config-wrapper/blob/master/LICENSE)
[![CircleCI](https://circleci.com/gh/drkostas/yaml-config-wrapper/tree/master.svg?style=svg)](https://circleci.com/gh/drkostas/yaml-config-wrapper/tree/master)A YAML configuration
wrapper. [PYPI Package](https://pypi.org/project/yaml-config-wrapper/)## Table of Contents
+ [Using the library](#using)
+ [Installing and using the library](#install_use)
+ [Creating a config file](#configuration)
+ [Set the required environment variables](#env_variables)
+ [Manually install the library](#manual_install)
+ [Prerequisites](#prerequisites)
+ [Install the requirements](#installing_req)
+ [Run the Unit Tests](#unit_tests)
+ [Continuous Integration](#ci)
+ [Update PyPI package](#pypi)
+ [License](#license)### Installing and using the library
First, you need to install the library either using pip:
```shell
$ pip install yaml_config_wrapper
```Then, import it and use it like so:
```python
from yaml_config_wrapper import Configuration# The `config_schema_path` argument is optional
conf = Configuration(config_src='confs/template_conf.yml',
config_schema_path='yml_schemas/default_schema.json')
```There are two already example yml configs
under [confs](https://github.com/drkostas/yaml-config-wrapper/tree/master/confs). An example structure
is the following:```yaml
tag: production
cloudstore:
config:
api_key: !ENV ${DROPBOX_API_KEY}
type: dropbox
datastore:
config:
hostname: !ENV ${MYSQL_HOST}
username: !ENV ${MYSQL_USERNAME}
password: !ENV ${MYSQL_PASSWORD}
db_name: !ENV ${MYSQL_DB_NAME}
port: 3306
type: mysql
email_app:
config:
email_address: !ENV ${EMAIL_ADDRESS}
api_key: !ENV ${GMAIL_API_KEY}
type: gmail
```The `!ENV` flag indicates that you are passing an environmental value to this attribute. You can change
the values/environmental var names as you wish.There is also the option to create a validation schema the enforces a specific yaml structure. The
default dummy version is
the [default_schema.json](https://github.com/drkostas/yaml-config-wrapper/blob/master/yaml_config_wrapper/default_schema.json)
file.### Set the required environment variables
In order to use the `!ENV` flag in you config, you need to set the corresponding environment variables
like so:```shell
$ export DROPBOX_API_KEY=123
$ export MYSQL_HOST=foo.rds.amazonaws.com
$ export MYSQL_USERNAME=user
$ export MYSQL_PASSWORD=pass
$ export MYSQL_DB_NAME=Test_schema
$ export EMAIL_ADDRESS=Gmail Bot
$ export GMAIL_API_KEY=123
```The best way to do that, is to create a .env
file ([example](https://github.com/drkostas/yaml-config-wrapper/blob/master/env_example)),
and source it before running the code.## Manually install the library
These instructions will get you a copy of the project up and running on your local machine for
development and testing purposes.You need to have a machine with
[anaconda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) installed and
any Bash based shell (e.g. zsh) installed.```ShellSession
$ conda -V
conda 4.10.1$ echo $SHELL
/usr/bin/zsh```
All the installation steps are being handled by
the [Makefile](https://github.com/drkostas/yaml-config-wrapper/blob/master/Makefile).First, modify the python version (`min_python`) and everything else you need in
the [settings.ini](https://github.com/drkostas/yaml-config-wrapper/blob/master/settings.ini).Then, execute the following commands:
```ShellSession
$ make create_env
$ conda activate yaml_config_wrapper
$ make dist
```Now you are ready to use and modify the library.
If you want to run the unit tests, execute the following command:
```ShellSession
$ make tests
```For the continuous integration, the CircleCI service is being used. For more information you can
check the [setup guide](https://circleci.com/docs/2.0/language-python/).Again, you should set
the [above-mentioned environmental variables](#env_variables) ([reference](https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-context))
and for any modifications, edit
the [circleci config](https://github.com/drkostas/yaml-config-wrapper/blob/master/.circleci/config.yml)
.This is mainly for future reference for the developers of this project. First,
create a file called `~/.pypirc` with your pypi login details, as follows:```
[pypi]
username = your_pypi_username
password = your_pypi_password
```Then, modify the python version (`min_python`), project status (`status`), release version (`version`)
and everything else you need in
the [settings.ini](https://github.com/drkostas/yaml-config-wrapper/blob/master/settings.ini).Finally, execute the following commands:
```ShellSession
$ make create_env
$ conda activate yaml_config_wrapper
$ make release
```For a dev release, change the `testing_version` and instead of `make release`, run `make release_test`.
This project is licensed under the Apache License - see
the [LICENSE](https://github.com/drkostas/yaml-config-wrapper/blob/master/LICENSE) file for
details.