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 validationSub-Pages
| Page | Description |
|---|---|
| Core Libraries | Configuration, logging, ports, and utilities |
| Helm Libraries | Deployment, repository, and template management |
| Kubernetes Libraries | Namespace, secret, and health operations |
| Azure Libraries | AKS, ACR, and Azure-specific operations |
| Validation Libraries | Pre-deploy, isolation, and integration validation |
Design Principles
-
Source guard. Every module uses a guard variable to prevent multiple sourcing:
[[ -n "${_MATIH_MODULE_LOADED:-}" ]] && return 0 readonly _MATIH_MODULE_LOADED=1 -
Explicit dependencies. Each module sources its required dependencies at the top.
-
No heredocs. All scripts use
printf,jq, or template files instead of heredoc syntax. -
JSON data interchange. Terraform outputs and build metadata are stored as JSON files and read with
jq.