feat: enhance manage.sh with image version display
This commit is contained in:
1 parent
01e1f20b21
commit
4be085d9d3
1 file changed
+42
-5
@@ -12,11 +12,6 @@ WHITELIST=()
|
||||
BLACKLIST=()
|
||||
PRIORITY=()
|
||||
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
bash -n "$CONFIG_FILE" || die "Syntax error in config file"
|
||||
source "$CONFIG_FILE"
|
||||
fi
|
||||
|
||||
DISCOVERED_STACKS=()
|
||||
MANAGED_STACKS=()
|
||||
|
||||
@@ -25,6 +20,11 @@ die() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
bash -n "$CONFIG_FILE" || die "Syntax error in config file: $CONFIG_FILE"
|
||||
source "$CONFIG_FILE"
|
||||
fi
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") COMMAND [STACK]
|
||||
@@ -40,6 +40,7 @@ Commands:
|
||||
ps Show container status
|
||||
logs Follow logs for a stack
|
||||
config Render Compose configuration for a stack
|
||||
images Show configured images and versions
|
||||
list List discovered stacks and their status
|
||||
EOF
|
||||
}
|
||||
@@ -187,6 +188,39 @@ list_stacks() {
|
||||
done
|
||||
}
|
||||
|
||||
stack_images() {
|
||||
local stack="$1"
|
||||
local output image
|
||||
|
||||
output="$(compose "$stack" config --images)" || return 1
|
||||
|
||||
while IFS= read -r image; do
|
||||
[[ -n "$image" ]] || continue
|
||||
printf '%-24s %s\n' "$stack" "$image"
|
||||
done <<<"$output"
|
||||
}
|
||||
|
||||
list_images() {
|
||||
local target="${1:-}"
|
||||
local stack
|
||||
local failed=0
|
||||
|
||||
printf '%-24s %s\n' "STACK" "IMAGE"
|
||||
printf '%-24s %s\n' "------------------------" "----------------------------------------"
|
||||
|
||||
if [[ -n "$target" ]]; then
|
||||
require_target "images" "$target"
|
||||
stack_images "$target"
|
||||
return
|
||||
fi
|
||||
|
||||
for stack in "${MANAGED_STACKS[@]}"; do
|
||||
stack_images "$stack" || ((failed += 1))
|
||||
done
|
||||
|
||||
((failed == 0))
|
||||
}
|
||||
|
||||
require_target() {
|
||||
local command="$1"
|
||||
local target="$2"
|
||||
@@ -240,6 +274,9 @@ config)
|
||||
require_target "$ACTION" "$TARGET"
|
||||
compose "$TARGET" config
|
||||
;;
|
||||
images)
|
||||
list_images "$TARGET"
|
||||
;;
|
||||
list)
|
||||
[[ -z "$TARGET" ]] || die "list does not accept a stack name"
|
||||
list_stacks
|
||||
|
||||
Reference in new issue
Block a user