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
| Function | Description |
|---|---|
tf_get_output | Read a Terraform output value from cached JSON or live state |
load_tf_infrastructure_env | Load all Terraform outputs into environment variables |
config_get_component_prop | Read a property from components.yaml |
config_get_components | List 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_nameThe 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
| Function | Output |
|---|---|
log_info | Green INFO prefix |
log_warn | Yellow WARN prefix |
log_error | Red ERROR prefix |
log_success | Green check mark |
log_debug | Blue DEBUG prefix (when DEBUG=true) |
log_section | Bold 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
| Function | Example 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
| Function | Description |
|---|---|
retry | Retry a command N times with backoff |
wait_for | Wait for a condition to become true |
require_command | Assert a CLI tool is installed |
is_ci | Check if running in CI environment |
errors.sh -- Error Handling
Module: scripts/lib/core/errors.sh
Error trap management and cleanup functions.
Functions
| Function | Description |
|---|---|
setup_error_trap | Install ERR and EXIT traps |
cleanup_on_exit | Register cleanup functions |
Related Pages
- Helm Libraries -- Helm deployment functions
- Kubernetes Libraries -- K8s operations
- Script Library Architecture -- Overview