ia_dev/deploy/lib/deploy-methodology.sh
Nicolas Cantu d80b240853 refactor(deploy): hoist shared conf handling to deploy/lib
**Motivations:**
- Apply approved boundary: identical steps in ia_dev libs; project orchestrator keeps only specific sequencing

**Root causes:**
- N/A

**Correctifs:**
- N/A

**Evolutions:**
- Add deploy/lib/deploy-conf-handling.sh (jq, secrets_path export, IA_DEV_DEPLOY_* context)
- Document boundary in deploy-methodology.sh; orchestrator sources new lib
- deploy/lib/README.md: boundary + deploy-conf-handling

**Pages affectées:**
- deploy/lib/*.sh, deploy/orchestrator.sh, deploy/lib/README.md
2026-03-23 13:23:23 +01:00

55 lines
2.2 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Shared deploy methodology for all ia_devmanaged projects: environments, quality bar, ordering contract.
# Sourced by ia_dev/deploy/deploy.sh and ia_dev/deploy/orchestrator.sh — no project-specific paths here.
#
# Boundary (approved workflow):
# - Everything strictly identical across projects (allowed envs, shared tooling checks, shared conf.json
# field handling) lives in deploy-methodology.sh and siblings under deploy/lib/ (e.g. deploy-conf-handling.sh).
# - The repositorys project orchestrator (deploy.project_orchestrator_path) only sequences project-specific
# work (e.g. LeCoffre: _lib/deploy-phase-*.sh, remote layout, Prisma, systemd unit names).
# When a step is candidate for hoisting, move it here or into a small deploy/lib/*.sh peer; shrink the project script.
# Environments are fixed across projects; extend only with an explicit decision and conf migration.
IA_DEV_DEPLOY_ENVS=(test pprod prod)
# ia_dev_deploy_env_is_allowed <word> — exit 0 if allowed
ia_dev_deploy_env_is_allowed() {
local e="${1:-}"
local x
for x in "${IA_DEV_DEPLOY_ENVS[@]}"; do
if [[ "$e" == "$x" ]]; then
return 0
fi
done
return 1
}
# ia_dev_deploy_assert_first_arg_env "$@" — first positional must be test|pprod|prod; stderr + exit 1 otherwise
ia_dev_deploy_assert_first_arg_env() {
if [[ $# -lt 1 ]]; then
echo "[ia_dev][deploy][ERROR] Missing <env> (expected: test | pprod | prod)" >&2
return 1
fi
local env_arg="$1"
ia_dev_deploy_assert_env_literal "$env_arg"
}
# ia_dev_deploy_assert_env_literal <env> — validate a single env token
ia_dev_deploy_assert_env_literal() {
local env_arg="${1:-}"
if [[ -z "$env_arg" ]]; then
echo "[ia_dev][deploy][ERROR] Missing <env> (expected: test | pprod | prod)" >&2
return 1
fi
if ! ia_dev_deploy_env_is_allowed "$env_arg"; then
echo "[ia_dev][deploy][ERROR] Invalid env '${env_arg}' (allowed: ${IA_DEV_DEPLOY_ENVS[*]})" >&2
return 1
fi
return 0
}
# ia_dev_deploy_log_methodology_banner — optional trace for support
ia_dev_deploy_log_methodology_banner() {
echo "[ia_dev][deploy] Methodology: envs={${IA_DEV_DEPLOY_ENVS[*]}} ; project orchestrator invoked after conf + secrets export (see orchestrator.sh)."
}