Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:173TECH Sayn Settings Configuration

From Leeroopedia
Knowledge Sources
Domains Configuration_Management, DevOps
Last Updated 2026-10-17 00:00 GMT

Overview

Pattern for layered configuration resolution that merges YAML-based settings with environment variables, enabling profile-based environment switching and 12-factor compliance.

Description

Settings configuration is the practice of resolving runtime configuration through multiple layers: a YAML file for structured, profile-based settings and environment variables for deployment-specific overrides. This solves the problem of managing different configurations across development, staging, and production environments without modifying code or project files.

Key concepts:

  • Profiles: Named configuration bundles (e.g., "dev", "prod") that encapsulate credentials, naming rules, and parameters
  • Environment variables: SAYN_* prefixed variables override or supplement YAML settings
  • Credential mapping: Profile credentials map settings.yaml names to project.yaml required_credentials
  • Stringify rules: Per-profile prefix/suffix/override for database object naming (dev vs prod)
  • from_prod: Glob patterns specifying which source tables should use production naming even in dev profiles
  • default_run: Default CLI arguments (include/exclude/upstream_prod) per profile

Usage

Use this principle when an application needs environment-specific configuration that can come from both files and environment variables. It is the right choice for data platforms deployed across multiple environments where credentials and naming conventions differ.

Theoretical Basis

The layered configuration resolution follows a precedence chain:

  1. Base: Empty configuration
  2. YAML layer: settings.yaml parsed into SettingsYaml model, profile selected via profile_name
  3. Environment layer: SAYN_* env vars parsed into Environment model (only merged when no profile specified)

The profile resolution algorithm (get_profile_info):

  • Resolve profile name (explicit or default_profile)
  • Extract non-None stringify values (prefix/suffix/override)
  • Map credential names from settings to project
  • Return from_prod globs and default_run settings

The environment variable regex: SAYN_((DATABASE|SCHEMA|TABLE)_(PREFIX|SUFFIX|OVERRIDE))|FROM_PROD|DEFAULT_RUN|PARAMETER_<name>|CREDENTIAL_<name>

Practical Guide

A settings.yaml file:

credentials:
  warehouse:
    type: postgresql
    host: localhost
    port: 5432
  api_db:
    type: sqlite
    path: ./data.db

profiles:
  dev:
    credentials:
      warehouse: warehouse
      api_db: api_db
    schema_prefix: dev
    from_prod:
      - "raw.*"
  prod:
    credentials:
      warehouse: warehouse_prod
      api_db: api_db_prod

default_profile: dev

Environment variable override:

export SAYN_SCHEMA_PREFIX=staging
export SAYN_FROM_PROD="raw.*,external.*"

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment