From b7b9dc91b4221c96dd89271735189b7f230e82ce Mon Sep 17 00:00:00 2001 From: poprhythm Date: Fri, 6 Mar 2026 03:55:53 +0000 Subject: [PATCH] Fix portainer.sh deploy: forward extra args (env vars) to cmd_deploy --- portainer.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/portainer.sh b/portainer.sh index c06edea..ada9459 100755 --- a/portainer.sh +++ b/portainer.sh @@ -134,15 +134,24 @@ cmd_deploy() { local name="${1:-}" local compose_path="${2:-}" if [[ -z "$name" || -z "$compose_path" ]]; then - echo "Usage: $0 deploy " >&2 - echo " Example: $0 deploy myapp myapp/docker-compose.yml" >&2 + echo "Usage: $0 deploy [KEY=VALUE ...]" >&2 + echo " Example: $0 deploy myapp myapp/docker-compose.yml FOO=bar BAZ=qux" >&2 exit 1 fi + shift 2 + local kvs=("$@") echo "Creating stack '$name' from $compose_path..." local payload payload=$(python3 -c " -import json +import json, sys + +kvs = sys.argv[1:] +env_list = [] +for kv in kvs: + eq = kv.index('=') + env_list.append({'name': kv[:eq], 'value': kv[eq+1:]}) + print(json.dumps({ 'name': '$name', 'repositoryURL': '$GITEA_REPO_URL', @@ -151,8 +160,9 @@ print(json.dumps({ 'repositoryAuthentication': True, 'repositoryUsername': '$GITEA_USER', 'repositoryPassword': '$GITEA_TOKEN', + 'env': env_list, })) -") +" "${kvs[@]}") local response response=$(api_post "stacks/create/standalone/repository?endpointId=${ENDPOINT_ID}" "$payload") @@ -282,7 +292,7 @@ command="${1:-}" case "$command" in list) cmd_list ;; redeploy) cmd_redeploy "${2:-}" ;; - deploy) cmd_deploy "${2:-}" "${3:-}" ;; + deploy) cmd_deploy "${@:2}" ;; get-env) cmd_get_env "${2:-}" ;; set-env) cmd_set_env "${2:-}" "${@:3}" ;; *) @@ -291,7 +301,7 @@ case "$command" in echo "Commands:" echo " list List all stacks" echo " redeploy Pull latest git commit and redeploy" - echo " deploy Create new git-linked stack" + echo " deploy [K=V ...] Create new git-linked stack with optional env vars" echo " get-env Show env vars for a stack" echo " set-env KEY=VAL [...] Set env vars (redeploys without new image pull)" exit 1