← Back to all products
$19
Config Manager
Layered configuration manager: merge defaults, files, env vars, and CLI overrides in precedence order with dot-path access, schema validation, secret masking, and diffing.
JSONMarkdownPython
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 11 files
config-manager/
├── LICENSE
├── README.md
├── examples/
│ ├── config_manager_config.json
│ └── schema.json
├── free-sample.zip
├── guide/
│ ├── 01_features.md
│ ├── 02_quick-start.md
│ ├── 03_output.md
│ └── 04_license.md
├── index.html
└── src/
└── config_manager.py
📖 Documentation Preview README excerpt
Config Manager
A layered configuration management library built on Python stdlib. Merge configuration from multiple sources in precedence order — built-in defaults, config files, environment variables, and CLI overrides — with dot-path access, schema validation, secret masking, and config diffing.
Features
- Layered merge — Defaults < config file < environment variables < CLI overrides, with deep recursive merging
- Multiple file formats — JSON, INI, and .env files supported out of the box
- Dot-path access — Get and set nested values with
database.hostnotation - Schema validation — Validate types, required keys, allowed values, numeric ranges, and regex patterns
- Type coercion — Automatic and explicit conversion between str, int, float, bool, and list types
- Secret masking — Export configs with passwords, tokens, and API keys automatically redacted
- Config diff — Compare two config files side-by-side with added/removed/changed reporting
- Environment variable overlay — Map
CFG_DATABASE__HOSTtodatabase.hostautomatically
Requirements
- Python 3.10+
- No external dependencies (stdlib only)
Quick Start
# Get a single value by dot-path
python src/config_manager.py --config examples/config_manager_config.json --get database.host
# Set an override and see the result
python src/config_manager.py --config examples/config_manager_config.json --set database.port=3306
# Validate config against a schema
python src/config_manager.py --config examples/config_manager_config.json --validate --schema examples/schema.json
# Export the full merged config (secrets masked)
python src/config_manager.py --config examples/config_manager_config.json --export
# List all dot-path keys
python src/config_manager.py --config examples/config_manager_config.json --keys
# Diff two config files
python src/config_manager.py --config examples/config_manager_config.json --diff examples/schema.json
Configuration Reference
CLI Options
| Flag | Default | Description |
|---|---|---|
--config, -c | — | Configuration file to load (JSON, INI, or .env) |
--get, -g | — | Get a value by dot-path (e.g. database.host) |
--set, -s | — | Set an override value (repeatable, e.g. --set db.port=5432) |
--validate, -V | — | Validate config against a schema file |
--schema | — | Schema file for --validate (JSON) |
--export, -e | — | Export merged config to stdout (secrets masked) |
--no-mask | — | Disable secret masking on --export |
--diff, -d | — | Show diff between loaded config and another file |
--keys, -k | — | List all dot-path keys in the merged config |
--env-prefix | CFG_ | Environment variable prefix |
--log-level | WARNING | Logging level (DEBUG, INFO, WARNING, ERROR) |
... continues with setup instructions, usage examples, and more.
📄 Code Sample .py preview
src/config_manager.py
#!/usr/bin/env python3
"""
Config Manager — Automation Hub (DataNest)
A layered configuration management library built on Python stdlib.
Merges configuration from multiple layers in precedence order:
built-in defaults < config file < environment variables < CLI overrides.
Supports JSON, INI, and .env files. Provides dot-path get/set,
type coercion, schema validation, secret masking, and config diffing.
Usage:
python config_manager.py --config app.json --get database.host
python config_manager.py --config app.json --set database.port=5432
python config_manager.py --config app.json --validate --schema schema.json
python config_manager.py --config app.json --export
python config_manager.py --config app.json --diff other.json
Dependencies: Python 3.10+ stdlib only (no pip packages)
License: MIT
"""
from __future__ import annotations
import argparse
import configparser
import copy
import json
import logging
import os
import re
import sys
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
LOG_FORMAT = "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
DEFAULT_ENV_PREFIX = "CFG_"
SECRET_PATTERNS = re.compile(
r"(password|secret|token|api_key|apikey|private_key|private|auth|credential)",
re.IGNORECASE,
)
MASKED_VALUE = "********"
logger = logging.getLogger("config_manager")
# ... 756 more lines ...