MATIH Platform is in active MVP development. Documentation reflects current implementation status.
18. CI/CD & Build System
Scripts Library
Script Library Architecture

Script Library Architecture

The MATIH scripts library (scripts/lib/) provides reusable Bash modules for Kubernetes operations, Helm deployments, Azure cloud management, and validation. All CD pipeline stages and tooling scripts source these libraries to avoid code duplication and ensure consistent behavior.


Library Structure

scripts/lib/
  core/              -- Core utilities
    config.sh        -- YAML parser, component registry, Terraform outputs
    logging.sh       -- Unified logging with colors and icons
    utils.sh         -- Utility functions (retry, wait, etc.)
    errors.sh        -- Error handling and trap management
    ports.sh         -- Port lookup from components.yaml
    deploy.sh        -- Deployment coordination
    version.sh       -- Version utilities
    versioning.sh    -- Semantic versioning
  helm/              -- Helm operations
    deploy.sh        -- Unified Helm deployment function
    repo.sh          -- Repository management
    template.sh      -- Values template engine
    versioning.sh    -- Chart version management
  k8s/               -- Kubernetes operations
    namespace.sh     -- Namespace creation and labeling
    secrets.sh       -- Secret CRUD operations
    dev-secrets.sh   -- Dev environment secret creation
    health.sh        -- Pod health checks and diagnostics
    build.sh         -- Build infrastructure management
    nodepool.sh      -- Nodepool scaling
  azure/             -- Azure-specific operations
    aks.sh           -- AKS cluster management
    acr.sh           -- Container Registry operations
    auth.sh          -- Azure authentication
    naming.sh        -- Resource naming conventions
    providers.sh     -- Azure resource provider registration
    aks-healing.sh   -- AKS self-healing and recovery
  validate/          -- Validation modules
    pre-deploy.sh    -- Pre-deployment checks
    isolation.sh     -- Tenant isolation validation
    integration.sh   -- Integration test runners
    pipeline.sh      -- Pipeline validation

Sub-Pages

PageDescription
Core LibrariesConfiguration, logging, ports, and utilities
Helm LibrariesDeployment, repository, and template management
Kubernetes LibrariesNamespace, secret, and health operations
Azure LibrariesAKS, ACR, and Azure-specific operations
Validation LibrariesPre-deploy, isolation, and integration validation

Design Principles

  1. Source guard. Every module uses a guard variable to prevent multiple sourcing:

    [[ -n "${_MATIH_MODULE_LOADED:-}" ]] && return 0
    readonly _MATIH_MODULE_LOADED=1
  2. Explicit dependencies. Each module sources its required dependencies at the top.

  3. No heredocs. All scripts use printf, jq, or template files instead of heredoc syntax.

  4. JSON data interchange. Terraform outputs and build metadata are stored as JSON files and read with jq.