feat: add support for specifying an initial-network property
This network is the network that is associated with the container on creation. If specified, then the bridge network is not attached to the service. Only a single initial network can be specified at this time.
This commit is contained in:
40
subcommands/set
Executable file
40
subcommands/set
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$PLUGIN_BASE_PATH/common/property-functions"
|
||||
|
||||
service-set-cmd() {
|
||||
#E set the network to attach after the service container is started
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:set lollipop post-create-network custom-network
|
||||
#E unset the post-create-network value
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:set lollipop post-create-network
|
||||
#A service, service to run command against
|
||||
#A key, property name to set
|
||||
#A value, optional property value to set or empty to unset key
|
||||
declare desc="set or clear a property for a service"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:set" argv=("$@")
|
||||
[[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare SERVICE="$1" KEY="$2" VALUE="$3"
|
||||
local VALID_KEYS=("post-create-network" "post-start-network" "initial-network")
|
||||
verify_service_name "$SERVICE"
|
||||
|
||||
[[ -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: network"
|
||||
fi
|
||||
|
||||
if [[ -n "$VALUE" ]]; then
|
||||
dokku_log_info2_quiet "Setting ${KEY} to ${VALUE}"
|
||||
fn-plugin-property-write "PLUGIN_COMMAND_PREFIX" "$SERVICE" "$KEY" "$VALUE"
|
||||
else
|
||||
dokku_log_info2_quiet "Unsetting ${KEY}"
|
||||
if [[ "$KEY" == "rev-env-var" ]]; then
|
||||
fn-plugin-property-write "PLUGIN_COMMAND_PREFIX" "$SERVICE" "$KEY" "$VALUE"
|
||||
else
|
||||
fn-plugin-property-delete "PLUGIN_COMMAND_PREFIX" "$SERVICE" "$KEY"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user