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

Core Libraries

The core libraries provide foundational utilities used by all other scripts: configuration parsing, logging, port management, error handling, and general-purpose functions.

Source: scripts/lib/core/


config.sh -- Configuration and Terraform Outputs

Module: scripts/lib/core/config.sh

Provides access to scripts/config/components.yaml (the port and service registry) and Terraform infrastructure outputs.

Key Functions

FunctionDescription
tf_get_outputRead a Terraform output value from cached JSON or live state
load_tf_infrastructure_envLoad all Terraform outputs into environment variables
config_get_component_propRead a property from components.yaml
config_get_componentsList all components in a category

Terraform Output Access

# Read from cached JSON (fast, created by stage 00)
ACR_NAME=$(tf_get_output acr_name "matihlabsacr")
 
# Falls back to: terraform -chdir=... output -raw acr_name

The cached file is at logs/deployment/.terraform_outputs.json.


logging.sh -- Unified Logging

Module: scripts/lib/core/logging.sh

Provides color-coded, icon-prefixed logging functions for consistent script output.

Functions

FunctionOutput
log_infoGreen INFO prefix
log_warnYellow WARN prefix
log_errorRed ERROR prefix
log_successGreen check mark
log_debugBlue DEBUG prefix (when DEBUG=true)
log_sectionBold section header

ports.sh -- Port Lookup

Module: scripts/lib/core/ports.sh

Reads service ports from scripts/config/components.yaml with an in-memory cache for performance.

Functions

FunctionExample Output
port_get_service_port "ai-service"8000
port_get_service_namespace "ai-service"matih-data-plane
port_get_service_health_path "ai-service"/health
port_get_service_url "ai-service"ai-service.matih-data-plane.svc.cluster.local:8000

utils.sh -- General Utilities

Module: scripts/lib/core/utils.sh

General-purpose functions used across all scripts.

Key Functions

FunctionDescription
retryRetry a command N times with backoff
wait_forWait for a condition to become true
require_commandAssert a CLI tool is installed
is_ciCheck if running in CI environment

errors.sh -- Error Handling

Module: scripts/lib/core/errors.sh

Error trap management and cleanup functions.

Functions

FunctionDescription
setup_error_trapInstall ERR and EXIT traps
cleanup_on_exitRegister cleanup functions

Related Pages