feat: add ability to manage stacks on an app or global level

The previous lever for manipulating this was the DOKKU_IMAGE environment variable. While this is all well and good, it only works for CNB and is yet another `DOKKU_*` environment variable that need not exist.

While this does not add support for manipulating the CNB stack just yet, the groundwork is set for the future.

Closes #4306
This commit is contained in:
Jose Diaz-Gonzalez committed 2021-01-23 16:19:12 -05:00
1 parent 4c74e0dfba
commit bad90b2b1d
11 files changed
+134 -8

No files matched your search

+26
View File
@@ -5,10 +5,36 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/dokku/dokku/plugins/common"
)
// TriggerBuildpackStackName echos the stack name for the app
func TriggerBuildpackStackName(appName string) error {
if stack := common.PropertyGetDefault("buildpacks", appName, "stack", ""); stack != "" {
fmt.Println(stack)
return nil
}
if stack := common.PropertyGetDefault("buildpacks", "--global", "stack", ""); stack != "" {
fmt.Println(stack)
return nil
}
b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_IMAGE"}...)
dokkuImage := strings.TrimSpace(string(b[:]))
if dokkuImage != "" {
common.LogWarn("Deprecated: use buildpacks:stacks-set instead of specifying DOKKU_IMAGE environment variable")
fmt.Println(dokkuImage)
return nil
}
fmt.Println(os.Getenv("DOKKU_IMAGE"))
return nil
}
// TriggerInstall runs the install step for the buildpacks plugin
func TriggerInstall() error {
if err := common.PropertySetup("buildpacks"); err != nil {