feat: split stack property into per-builder properties
The `stack` property lived on the `buildpacks` plugin but was shared by both the herokuish and pack builders, so a value valid for one builder broke the other. Each builder now owns its own `stack` property managed via `builder-herokuish:set` and `builder-pack:set`, while `buildpacks:set-property stack` is deprecated and forwards the value to the builder detected from it; existing values migrate automatically on upgrade and changing a builder's stack clears that builder's cache.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/builder-herokuish/internal-functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
|
||||
fn-builder-herokuish-ensure-cache() {
|
||||
@@ -23,7 +24,8 @@ trigger-builder-herokuish-builder-build() {
|
||||
return
|
||||
fi
|
||||
|
||||
local stack="$(plugn trigger buildpack-stack-name "$APP")"
|
||||
local stack="$(fn-builder-herokuish-stack "$APP")"
|
||||
[[ -z "$stack" ]] && stack="$(fn-builder-herokuish-global-stack "$APP")"
|
||||
if [[ -n "$stack" ]]; then
|
||||
dokku_log_info1 "Building $APP from $stack"
|
||||
DOKKU_IMAGE="$stack"
|
||||
|
||||
@@ -28,3 +28,27 @@ fn-builder-herokuish-allowed() {
|
||||
|
||||
fn-plugin-property-get-default "builder-herokuish" "$APP" "allowed" ""
|
||||
}
|
||||
|
||||
fn-builder-herokuish-computed-stack() {
|
||||
declare APP="$1"
|
||||
|
||||
stack="$(fn-builder-herokuish-stack "$APP")"
|
||||
if [[ -z "$stack" ]]; then
|
||||
stack="$(fn-builder-herokuish-global-stack "$APP")"
|
||||
fi
|
||||
if [[ -z "$stack" ]]; then
|
||||
stack="${DOKKU_IMAGE:-gliderlabs/herokuish:latest-24}"
|
||||
fi
|
||||
|
||||
echo "$stack"
|
||||
}
|
||||
|
||||
fn-builder-herokuish-global-stack() {
|
||||
fn-plugin-property-get-default "builder-herokuish" "--global" "stack" ""
|
||||
}
|
||||
|
||||
fn-builder-herokuish-stack() {
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "builder-herokuish" "$APP" "stack" ""
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package builderherokuish
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
@@ -17,12 +19,17 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
|
||||
flags = map[string]common.ReportFunc{
|
||||
"--builder-herokuish-computed-allowed": reportComputedAllowed,
|
||||
"--builder-herokuish-global-allowed": reportGlobalAllowed,
|
||||
"--builder-herokuish-computed-stack": reportComputedStack,
|
||||
"--builder-herokuish-global-stack": reportGlobalStack,
|
||||
}
|
||||
} else {
|
||||
flags = map[string]common.ReportFunc{
|
||||
"--builder-herokuish-computed-allowed": reportComputedAllowed,
|
||||
"--builder-herokuish-global-allowed": reportGlobalAllowed,
|
||||
"--builder-herokuish-allowed": reportAllowed,
|
||||
"--builder-herokuish-computed-stack": reportComputedStack,
|
||||
"--builder-herokuish-global-stack": reportGlobalStack,
|
||||
"--builder-herokuish-stack": reportStack,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +75,29 @@ func reportComputedAllowed(appName string) string {
|
||||
return allowed
|
||||
}
|
||||
|
||||
func reportStack(appName string) string {
|
||||
return common.PropertyGet("builder-herokuish", appName, "stack")
|
||||
}
|
||||
|
||||
func reportGlobalStack(appName string) string {
|
||||
return common.PropertyGet("builder-herokuish", "--global", "stack")
|
||||
}
|
||||
|
||||
func reportComputedStack(appName string) string {
|
||||
stack := reportStack(appName)
|
||||
if stack == "" {
|
||||
stack = reportGlobalStack(appName)
|
||||
}
|
||||
if stack == "" {
|
||||
stack = os.Getenv("DOKKU_IMAGE")
|
||||
}
|
||||
if stack == "" {
|
||||
stack = "gliderlabs/herokuish:latest-24"
|
||||
}
|
||||
|
||||
return stack
|
||||
}
|
||||
|
||||
// hostArchitecture returns the dpkg architecture of the host, or an empty string
|
||||
// when it cannot be determined (matching the bash `dpkg --print-architecture` check)
|
||||
func hostArchitecture() string {
|
||||
|
||||
@@ -9,13 +9,13 @@ cmd-builder-herokuish-set() {
|
||||
declare cmd="builder-herokuish:set"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1" KEY="$2" VALUE="$3"
|
||||
local VALID_KEYS=("allowed")
|
||||
local VALID_KEYS=("allowed" "stack")
|
||||
[[ "$APP" == "--global" ]] || 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: allowed"
|
||||
dokku_log_fail "Invalid key specified, valid keys include: allowed, stack"
|
||||
fi
|
||||
|
||||
if [[ -n "$VALUE" ]]; then
|
||||
@@ -25,6 +25,14 @@ cmd-builder-herokuish-set() {
|
||||
dokku_log_info2_quiet "Unsetting ${KEY}"
|
||||
fn-plugin-property-delete "builder-herokuish" "$APP" "$KEY"
|
||||
fi
|
||||
|
||||
if [[ "$KEY" == "stack" ]]; then
|
||||
if [[ "$APP" == "--global" ]]; then
|
||||
for app in $(dokku_apps 2>/dev/null || true); do plugn trigger post-stack-set "$app" "$VALUE"; done
|
||||
else
|
||||
plugn trigger post-stack-set "$APP" "$VALUE"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
cmd-builder-herokuish-set "$@"
|
||||
|
||||
Reference in New Issue
Block a user