No project description provided
Project description
JSON Schema Application Environment Configuration and Validation
This package allows you to validate application environment variables that are used for configuration with JSON schemas.
It is extremely useful to use with Docker/kubernetes where you might have quite a bit of configuration originating from environment variables; however, it also provides a nice generic way to define and validate any application configuration with JSON Schema.
Usage
First, define a JSON Schema file(env-schema.json
):
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"db_uri": {
"type": "string",
"title": "AMQP host"
}
},
"required": ["db_uri"]
}
Then, validate your environment config(export DB_URI=postgresql://localhost:5432
):
import enviral
settings = enviral.validate_env('env-schema.json')
settings['db_uri']
Validate with multiple files:
import enviral
settings = enviral.validate_env('env-schema.json', 'package:validation-file.json')
You can also validate existing objects against JSON schema files:
import enviral
enviral.validate_object({"db_uri": "postgresql://localhost:5432"}, 'env-schema.json')
Or command line validate:
json-schema-env-validator env-schema.json package:validation-file.json
Development
pip install -r requirements.txt
pip install -e .
./bin/pre-commit install
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for json-schema-env-validator-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b54b1aaa788abe3b97a025bfa0a345e758256c37bad55c13f7979541bf8e2d27 |
|
MD5 | d585fccbac975e1fb00adf5a7e18ff4a |
|
BLAKE2b-256 | 5d94d23732ffb96a509decfca8c865820f2161735ba91b2c55bdaf0cbcf1d2c7 |
Hashes for json_schema_env_validator-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84b9992e116adb166b4f73828a240b7ae15af3e92e2c1f36a32dca8a299954b1 |
|
MD5 | 3ffc2b2ddf94b1eb45c7c326c1741148 |
|
BLAKE2b-256 | 3bd265f2d6d98cc9324b413a2a2d9674c6c8d415d149ec52200d421b9e9bd615 |