Files
dokku/plugins/proxy/command-functions
T
Jose Diaz-Gonzalez 9df45f6a6e fix: serialize concurrent property updates
Concurrent commands for the same app could each read a setting, change it, and write it back, so all of them exited successfully while silently dropping changes made by the others. Updates to app settings are now serialized so every change is kept, and readers never see a partially written value.
2026-10-21 21:21:57 -04:00

56 lines
2.0 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/proxy/functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-proxy-labels-show() {
declare desc="show a proxy label for an app"
declare cmd="proxy:labels:show"
[[ "$1" == "$cmd" ]] && shift 1
declare PROXY="$1" APP="$2" PASSED_LABEL_NAME="$3"
[[ -z "$PROXY" ]] && dokku_log_fail "Error invoking proxy:labels:show command"
verify_app_name "$APP"
if [[ -n "$PASSED_LABEL_NAME" ]]; then
fn-proxy-show-label "$PROXY" "$APP" "$PASSED_LABEL_NAME"
return
fi
fn-proxy-display-labels "$PROXY" "$APP"
}
cmd-proxy-labels-add() {
declare desc="adds container label to app for specified proxy"
declare cmd="proxy:labels:add"
[[ "$1" == "$cmd" ]] && shift 1
declare PROXY="$1" APP="$2" PASSED_LABEL_NAME="$3" PASSED_LABEL_VALUE="$4"
[[ -z "$PROXY" ]] && dokku_log_fail "Error invoking proxy:labels:add command"
[[ -z "$PASSED_LABEL_NAME" ]] && dokku_log_fail "Please specify a container label for the app"
[[ -z "$PASSED_LABEL_VALUE" ]] && dokku_log_fail "Please specify a value for the container label"
verify_app_name "$APP"
fn-plugin-property-lock "$PROXY" "$APP" fn-proxy-labels-add "$PROXY" "$APP" "$PASSED_LABEL_NAME" "$PASSED_LABEL_VALUE"
}
cmd-proxy-labels-remove() {
declare desc="removes container label from app for specified proxy"
declare cmd="proxy:labels:remove"
[[ "$1" == "$cmd" ]] && shift 1
declare PROXY="$1" APP="$2" PASSED_LABEL_NAME="$3"
[[ -z "$PROXY" ]] && dokku_log_fail "Error invoking proxy:labels:remove command"
[[ -z "$PASSED_LABEL_NAME" ]] && dokku_log_fail "Please specify a container label for the app"
verify_app_name "$APP"
local proxy_labels_file_path="$(fn-proxy-get-labels-file-path "$PROXY" "$APP")"
if [[ ! -s "$proxy_labels_file_path" ]]; then
return
fi
fn-plugin-property-lock "$PROXY" "$APP" fn-proxy-labels-remove "$PROXY" "$APP" "$PASSED_LABEL_NAME"
}