builder-nixpacks/subcommands/set

32 lines
1.0 KiB
Plaintext
Raw Normal View History

2022-08-30 10:26:44 -04:00
#!/usr/bin/env bash
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
2022-08-30 10:50:04 -04:00
source "$PLUGIN_AVAILABLE_PATH/builder-nixpacks/internal-functions"
2022-08-30 10:26:44 -04:00
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"
2022-08-30 10:50:04 -04:00
local VALID_KEYS=$(fn-builder-nixpacks-valid-keys)
2022-08-30 10:26:44 -04:00
verify_app_name "$APP"
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
2022-08-30 11:27:56 -04:00
if ! is_val_in_list "$KEY" "$VALID_KEYS" " "; then
dokku_log_fail "Invalid key specified, valid keys include: $VALID_KEYS"
2022-08-30 10:26:44 -04:00
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 "$@"