- Extend DeployParams and UpdateParams with strict no_cache boolean implying build=True - Wire --build and --no-cache on appctl up, deploy, and update CLI commands - Update bash completion to suggest --build and --no-cache for up and update - Pass --pull (and --no-cache when requested) on docker compose build in OperationalRouter - Add comprehensive unit tests covering contract validation, CLI arguments, and router subprocess calls Refs #11
113 lines
3.7 KiB
Bash
Executable File
113 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# appctl - Unified, Manifest-Driven Container Orchestrator
|
|
# Thin CLI wrapper delegating operational commands to homelab-appctl.service over UDS
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ENGINE="$SCRIPT_DIR/appctl_engine.py"
|
|
if [ -z "$PYTHON_BIN" ]; then
|
|
if [ -x "$SCRIPT_DIR/../.venv/bin/python3" ]; then
|
|
PYTHON_BIN="$SCRIPT_DIR/../.venv/bin/python3"
|
|
else
|
|
PYTHON_BIN="python3"
|
|
fi
|
|
fi
|
|
SOCKET_PATH="${APPCTL_SOCKET_PATH:-/run/homelab/appctl.sock}"
|
|
CLI_CLIENT="$SCRIPT_DIR/appctl_cli.py"
|
|
|
|
# Fast-path local shell completion helpers
|
|
case "${1:-}" in
|
|
complete)
|
|
exec "$PYTHON_BIN" "$ENGINE" complete "${@:2}"
|
|
;;
|
|
completion)
|
|
cat <<'EOF'
|
|
_appctl_completions() {
|
|
local cur prev words cword
|
|
if declare -F _init_completion >/dev/null 2>&1; then
|
|
_init_completion || return
|
|
else
|
|
COMPREPLY=()
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
words=("${COMP_WORDS[@]}")
|
|
cword=$COMP_CWORD
|
|
fi
|
|
|
|
local commands="list status ssl info up down restart update pull logs config sync health resolve completion"
|
|
|
|
if [ "$cword" -eq 1 ]; then
|
|
COMPREPLY=( $(compgen -W "$commands" -- "$cur") )
|
|
return 0
|
|
fi
|
|
|
|
local command="${words[1]}"
|
|
local appctl_cmd="${words[0]}"
|
|
|
|
case "$command" in
|
|
list|status)
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $(compgen -W "--fetch -f --core -c --ssl -s --all -a" -- "$cur") )
|
|
fi
|
|
;;
|
|
ssl)
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $(compgen -W "--core -c --all -a" -- "$cur") )
|
|
else
|
|
local services
|
|
services=$("$appctl_cmd" complete services 2>/dev/null || appctl complete services 2>/dev/null || true)
|
|
COMPREPLY=( $(compgen -W "$services" -- "$cur") )
|
|
fi
|
|
;;
|
|
info)
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $(compgen -W "--ssl -s" -- "$cur") )
|
|
else
|
|
local services
|
|
services=$("$appctl_cmd" complete services 2>/dev/null || appctl complete services 2>/dev/null || true)
|
|
COMPREPLY=( $(compgen -W "$services" -- "$cur") )
|
|
fi
|
|
;;
|
|
up|deploy)
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $(compgen -W "--build --no-cache" -- "$cur") )
|
|
else
|
|
local services
|
|
services=$("$appctl_cmd" complete services 2>/dev/null || appctl complete services 2>/dev/null || true)
|
|
COMPREPLY=( $(compgen -W "$services" -- "$cur") )
|
|
fi
|
|
;;
|
|
update)
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $(compgen -W "--branch --build --no-cache" -- "$cur") )
|
|
else
|
|
local services
|
|
services=$("$appctl_cmd" complete services 2>/dev/null || appctl complete services 2>/dev/null || true)
|
|
COMPREPLY=( $(compgen -W "$services" -- "$cur") )
|
|
fi
|
|
;;
|
|
down|restart|pull|logs|config)
|
|
local services
|
|
services=$("$appctl_cmd" complete services 2>/dev/null || appctl complete services 2>/dev/null || true)
|
|
COMPREPLY=( $(compgen -W "$services" -- "$cur") )
|
|
;;
|
|
completion)
|
|
COMPREPLY=( $(compgen -W "bash" -- "$cur") )
|
|
;;
|
|
esac
|
|
}
|
|
complete -F _appctl_completions appctl
|
|
EOF
|
|
exit 0
|
|
;;
|
|
*)
|
|
if [ ! -S "$SOCKET_PATH" ]; then
|
|
echo "❌ Error: appctl daemon socket not found at $SOCKET_PATH. Ensure homelab-appctl.service is running." >&2
|
|
exit 1
|
|
fi
|
|
exec "$PYTHON_BIN" "$CLI_CLIENT" "$@"
|
|
;;
|
|
esac
|