builder-nixpacks/subcommands/set

44 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
source "$PLUGIN_AVAILABLE_PATH/builder-nixpacks/internal-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-builder-nixpacks-set() {
declare desc="set or clear a builder-nixpacks property for an app"
declare cmd="builder-nixpacks:set"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" KEY="$2" VALUE="$3"
local VALID_KEYS=$(fn-builder-nixpacks-valid-keys)
local VALID_KEYS=(\
"NIXPACKS_APT_PKGS" \
"NIXPACKS_BUILD_CACHE_DIRS" \
"NIXPACKS_BUILD_CMD" \
"NIXPACKS_INSTALL_CACHE_DIRS" \
"NIXPACKS_INSTALL_CMD" \
"NIXPACKS_LIBS" \
"NIXPACKS_NO_CACHE" \
"NIXPACKS_NO_MUSL" \
"NIXPACKS_PKGS" \
"NIXPACKS_START_CMD" \
)
verify_app_name "$APP"
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
dokku_log_fail "Invalid key specified, valid keys include: ${VALID_KEYS[@]}"
fi
if [[ -n "$VALUE" ]]; then
dokku_log_info2_quiet "Setting ${KEY} to ${VALUE}"
fn-plugin-property-write "builder-nixpacks" "$APP" "$KEY" "$VALUE"
else
dokku_log_info2_quiet "Unsetting ${KEY}"
fn-plugin-property-delete "builder-nixpacks" "$APP" "$KEY"
fi
}
cmd-builder-nixpacks-set "$@"