chain commands, and let a project refine a catalogue stack
myos build up logs host/fabio runs the three in order and stops at the first failure, the way make build up logs STACK=host/fabio did. Leading words that name commands are commands; the first word that is not one starts the stacks. A stack found in several directories of the stack path is now merged rather than shadowed, least specific first, so a project drops stack/postgres/postgres.local.yml next to the catalogue's postgres.yml and refines it. Settings hooks follow the same order, so a project can redefine a default the catalogue ships. Neither engine did this before: the project directory simply hid the catalogue one. An unknown command now says so and suggests the command to type, instead of printing the whole usage.
This commit is contained in:
@@ -44,6 +44,37 @@ myos_stack_version() {
|
||||
case $_r in *:*) printf '%s' "${_r##*:}" ;; *) printf 'latest' ;; esac
|
||||
}
|
||||
|
||||
# myos_stack_dirs REF every directory of MYOS_PATH holding this stack, least
|
||||
# specific first. A compose overlay wins over the ones before it, so a project
|
||||
# that ships stack/postgres/postgres.local.yml refines the postgres stack of
|
||||
# the catalogue instead of replacing it.
|
||||
myos_stack_dirs() {
|
||||
_ref=${1%/}
|
||||
case $_ref in *:*) _ref=${_ref%:*} ;; esac
|
||||
_name=$(myos_stack_name "$1")
|
||||
case $_ref in
|
||||
.|./*|/*|../*)
|
||||
[ -d "$_ref" ] && (cd "$_ref" && pwd -P)
|
||||
return 0 ;;
|
||||
esac
|
||||
_found=
|
||||
_IFS=$IFS; IFS=:
|
||||
for _d in $(myos_path); do
|
||||
IFS=$_IFS
|
||||
_hit=
|
||||
if [ -d "$_d/$_ref" ]; then _hit=$_d/$_ref
|
||||
elif [ -f "$_d/$_ref.yml" ] || [ -f "$_d/$_ref.yaml" ]; then _hit=$(dirname "$_d/$_ref")
|
||||
elif [ -d "$_d/$_name" ]; then _hit=$_d/$_name
|
||||
fi
|
||||
# least specific last here, then reversed below
|
||||
[ -n "$_hit" ] && _found="$_hit
|
||||
$_found"
|
||||
IFS=:
|
||||
done
|
||||
IFS=$_IFS
|
||||
printf '%s' "$_found" | sed '/^$/d'
|
||||
}
|
||||
|
||||
# myos_stack_resolve REF print the directory holding the stack,
|
||||
# or fail with MYOS_E_NOSTACK
|
||||
myos_stack_resolve() {
|
||||
|
||||
Reference in New Issue
Block a user