Skip to main content

Cascading Configuration Manager - deep-merge configuration files across multiple directories

Project description

CasConf

Cascading Configuration Manager

CasConf is a flexible configuration management tool that deep-merges configuration files across multiple directories following a cascading pattern.

Overview

CasConf scans a configurable list of directories for matching configuration files and intelligently deep-merges them based on discovery order. The result is a single, unified configuration that respects the cascade hierarchy you define.

Key Features

  • Deep Merging: Recursively merges nested configuration structures
  • Format Agnostic: Supports JSON, YAML, TOML, and INI formats
  • Configurable Discovery: Define your own directory scan order

Use Cases

  • Application configuration across development, staging, and production environments
  • User-specific configuration overrides (system → user → project)
  • Plugin or module configuration aggregation
  • Multi-tenant configuration management
  • Dotfile management and system configuration

Documentation

Installation

# From PyPI (when published)
pip install casconf

# From source
pip install git+https://github.com/ConsoleCatzirl/casconf.git@main

Basic Usage

Command-Line Interface

# Merge configs and output to stdout (default)
casconf --discovery-config ./casconf.yaml

# Output to a file
casconf --discovery-config ./casconf.yaml --output ./merged.json

# Specify output format
casconf --discovery-config ./casconf.yaml --format yaml

# Configure with environment variables
export CASCONF_DISCOVERY=./casconf.yaml
export CASCONF_OUTPUT=./merged.json
export CASCONF_FORMAT=json
casconf

# Pipe to other tools
casconf | jq '.database'

Library Usage

from casconf import merge_configs

# Merge and return configuration data
config_data = merge_configs(discovery_config='./casconf.yaml')

# Merge and write to file in one call
merge_configs(
    discovery_config='./casconf.yaml',
    output='./output/config.json',
    output_format='json'
)
from casconf import merge_configs, DiscoveryConfig

# Build a DiscoveryConfig programmatically (no file required)
discovery = DiscoveryConfig(
    directories=[
        '/etc/myapp/defaults',
        '/etc/myapp/$ENVIRONMENT',   # expanded at runtime, e.g. production
        '~/.config/myapp',
    ],
    patterns=['config.json', 'config.yaml'],
    merge_strategy='deep',
)

config = merge_configs(discovery_config=discovery)

Discovery Configuration

CasConf uses a discovery configuration file to determine where to search for configuration files:

# casconf.yaml
directories:
  - /etc/myapp/defaults        # site-wide defaults
  - /etc/myapp/$ENVIRONMENT    # environment-specific overrides, e.g. production, staging
  - /etc/myapp/$HOSTNAME       # host-specific overrides, e.g. web-01.example.com
  - ~/.config/myapp            # user overrides (highest priority)

patterns:
  - "config.json"
  - "config.yaml"
  - "*.conf.json"

merge_strategy: deep  # or 'shallow'

Directory paths support ~ expansion and $VAR / ${VAR} environment variable expansion. Missing directories are skipped with a warning — no error is raised. See USAGE.md for a full walkthrough.

License

This project is dual-licensed:

  • MIT License: When used as a standalone executable (CLI tool)
  • GNU General Public License v3.0 (GPL-3.0): When imported or linked as a library

See LICENSE for full details.

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

This project follows PEP 8 style guidelines and emphasizes simplicity and maintainability.

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

casconf-0.2.0.tar.gz (55.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

casconf-0.2.0-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file casconf-0.2.0.tar.gz.

File metadata

  • Download URL: casconf-0.2.0.tar.gz
  • Upload date:
  • Size: 55.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for casconf-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d5287cf9f794911912a26fc59a4dc6d41cccd1b5063d39bc425c3d85c2b1bf9c
MD5 9832ebb87bab5edd43199071d99eb52b
BLAKE2b-256 a5916522f121d9c417239085a872594c874c4584327da290a730d2e72e246e89

See more details on using hashes here.

Provenance

The following attestation bundles were made for casconf-0.2.0.tar.gz:

Publisher: release.yaml on ConsoleCatzirl/casconf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file casconf-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: casconf-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for casconf-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ce1c9de5267d98872363a0d7bfba0da211af97daa664529b021e1fedac73f13
MD5 568ec34cf8c6c9fc1c1e18920adb3626
BLAKE2b-256 cbecaff42202dd0031d5b676dd6361d31f2d1c7880b02af452993d468d1372e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for casconf-0.2.0-py3-none-any.whl:

Publisher: release.yaml on ConsoleCatzirl/casconf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page