Fix portainer.sh deploy: forward extra args (env vars) to cmd_deploy
This commit is contained in:
+16
-6
@@ -134,15 +134,24 @@ cmd_deploy() {
|
|||||||
local name="${1:-}"
|
local name="${1:-}"
|
||||||
local compose_path="${2:-}"
|
local compose_path="${2:-}"
|
||||||
if [[ -z "$name" || -z "$compose_path" ]]; then
|
if [[ -z "$name" || -z "$compose_path" ]]; then
|
||||||
echo "Usage: $0 deploy <stack-name> <compose-path>" >&2
|
echo "Usage: $0 deploy <stack-name> <compose-path> [KEY=VALUE ...]" >&2
|
||||||
echo " Example: $0 deploy myapp myapp/docker-compose.yml" >&2
|
echo " Example: $0 deploy myapp myapp/docker-compose.yml FOO=bar BAZ=qux" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
shift 2
|
||||||
|
local kvs=("$@")
|
||||||
|
|
||||||
echo "Creating stack '$name' from $compose_path..."
|
echo "Creating stack '$name' from $compose_path..."
|
||||||
local payload
|
local payload
|
||||||
payload=$(python3 -c "
|
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({
|
print(json.dumps({
|
||||||
'name': '$name',
|
'name': '$name',
|
||||||
'repositoryURL': '$GITEA_REPO_URL',
|
'repositoryURL': '$GITEA_REPO_URL',
|
||||||
@@ -151,8 +160,9 @@ print(json.dumps({
|
|||||||
'repositoryAuthentication': True,
|
'repositoryAuthentication': True,
|
||||||
'repositoryUsername': '$GITEA_USER',
|
'repositoryUsername': '$GITEA_USER',
|
||||||
'repositoryPassword': '$GITEA_TOKEN',
|
'repositoryPassword': '$GITEA_TOKEN',
|
||||||
|
'env': env_list,
|
||||||
}))
|
}))
|
||||||
")
|
" "${kvs[@]}")
|
||||||
|
|
||||||
local response
|
local response
|
||||||
response=$(api_post "stacks/create/standalone/repository?endpointId=${ENDPOINT_ID}" "$payload")
|
response=$(api_post "stacks/create/standalone/repository?endpointId=${ENDPOINT_ID}" "$payload")
|
||||||
@@ -282,7 +292,7 @@ command="${1:-}"
|
|||||||
case "$command" in
|
case "$command" in
|
||||||
list) cmd_list ;;
|
list) cmd_list ;;
|
||||||
redeploy) cmd_redeploy "${2:-}" ;;
|
redeploy) cmd_redeploy "${2:-}" ;;
|
||||||
deploy) cmd_deploy "${2:-}" "${3:-}" ;;
|
deploy) cmd_deploy "${@:2}" ;;
|
||||||
get-env) cmd_get_env "${2:-}" ;;
|
get-env) cmd_get_env "${2:-}" ;;
|
||||||
set-env) cmd_set_env "${2:-}" "${@:3}" ;;
|
set-env) cmd_set_env "${2:-}" "${@:3}" ;;
|
||||||
*)
|
*)
|
||||||
@@ -291,7 +301,7 @@ case "$command" in
|
|||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " list List all stacks"
|
echo " list List all stacks"
|
||||||
echo " redeploy <stack-name> Pull latest git commit and redeploy"
|
echo " redeploy <stack-name> Pull latest git commit and redeploy"
|
||||||
echo " deploy <stack-name> <path> Create new git-linked stack"
|
echo " deploy <stack-name> <path> [K=V ...] Create new git-linked stack with optional env vars"
|
||||||
echo " get-env <stack-name> Show env vars for a stack"
|
echo " get-env <stack-name> Show env vars for a stack"
|
||||||
echo " set-env <stack-name> KEY=VAL [...] Set env vars (redeploys without new image pull)"
|
echo " set-env <stack-name> KEY=VAL [...] Set env vars (redeploys without new image pull)"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user