Files
myos/lib/hooks.sh
T
Yann Autissier 6192d73cbe port the make list functions and JWT, and expose the framework variables to hooks
lib/str.sh gains firstword, lastword, or, patsubst, filter, filter_out,
addprefix, addsuffix and jwt: what the catalogue .mk files are written in.
The make JWT macro split on the commas of its payload; this one does not.

lib/context.sh registers COMPOSE_PROJECT_NAME, APP, DOCKER_NETWORK_* and the
rest as lazy defaults, so a converted .mk keeps reading them as it did.

Hooks also load a directory-level _stack.env and _stack.sh, for the .mk files
of the catalogue that hold settings for several stacks at once.
2026-09-03 21:58:22 +02:00

31 lines
1.1 KiB
Bash

#shellcheck shell=sh
# hooks: the per-stack settings that used to live in a .mk file.
#
# A stack may ship, next to its compose files:
# _stack.env settings shared by every stack of the directory
# _stack.sh the same, computed
# <name>.env dotenv, for plain values
# <name>.env.<env> the same, for one environment
# <name>.sh shell, for values that have to be computed (fabio tags, JWTs)
# <name>.mk the legacy make snippet, still read for its groups
#
# A .sh hook runs with the myos helpers available (myos_tagprefix, myos_uri,
# myos_var) and sets variables directly. This is what lets a stack of the
# catalogue work on a machine that has no make.
# myos_stack_hooks DIR NAME load the hooks of one stack, most specific last
myos_stack_hooks() {
_hdir=$1; _hname=$2
for _h in "$_hdir/_stack.env" "$_hdir/$_hname.env" "$_hdir/$_hname.env.$ENV"; do
[ -f "$_h" ] && myos_dotenv_load "$_h"
done
for _h in "$_hdir/_stack.sh" "$_hdir/$_hname.sh" "$_hdir/$_hname.$ENV.sh"; do
if [ -f "$_h" ]; then
myos_debug "hook $_h"
# shellcheck source=/dev/null
. "$_h"
fi
done
return 0
}