2019-01-21 19:41:49 -05:00
|
|
|
package buildpacks
|
|
|
|
|
|
|
|
|
|
import (
|
2021-01-17 23:20:16 -05:00
|
|
|
"os"
|
2019-01-21 19:41:49 -05:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/dokku/dokku/plugins/common"
|
|
|
|
|
)
|
|
|
|
|
|
2021-01-20 14:49:32 -05:00
|
|
|
// ReportSingleApp is an internal function that displays the buildpacks report for one or more apps
|
2021-02-01 22:23:05 -05:00
|
|
|
func ReportSingleApp(appName string, format string, infoFlag string) error {
|
2019-01-21 19:41:49 -05:00
|
|
|
if err := common.VerifyAppName(appName); err != nil {
|
2020-02-22 06:29:14 -05:00
|
|
|
return err
|
2019-01-21 19:41:49 -05:00
|
|
|
}
|
|
|
|
|
|
2020-12-29 23:56:10 -05:00
|
|
|
flags := map[string]common.ReportFunc{
|
2021-01-17 23:20:16 -05:00
|
|
|
"--buildpacks-computed-stack": reportComputedStack,
|
|
|
|
|
"--buildpacks-global-stack": reportGlobalStack,
|
|
|
|
|
"--buildpacks-list": reportList,
|
|
|
|
|
"--buildpacks-stack": reportStack,
|
2019-01-21 19:41:49 -05:00
|
|
|
}
|
|
|
|
|
|
2021-01-07 01:34:05 -05:00
|
|
|
flagKeys := []string{}
|
|
|
|
|
for flagKey := range flags {
|
|
|
|
|
flagKeys = append(flagKeys, flagKey)
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-09 20:37:03 -05:00
|
|
|
trimPrefix := false
|
|
|
|
|
uppercaseFirstCharacter := true
|
2020-12-30 00:37:43 -05:00
|
|
|
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
2021-02-01 22:23:05 -05:00
|
|
|
return common.ReportSingleApp("buildpacks", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
|
2019-01-21 19:41:49 -05:00
|
|
|
}
|
2020-12-29 23:56:10 -05:00
|
|
|
|
2021-01-17 23:20:16 -05:00
|
|
|
func reportComputedStack(appName string) string {
|
|
|
|
|
if stack := common.PropertyGetDefault("buildpacks", appName, "stack", ""); stack != "" {
|
|
|
|
|
return stack
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if stack := common.PropertyGetDefault("buildpacks", "--global", "stack", ""); stack != "" {
|
|
|
|
|
return stack
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-14 01:18:28 -04:00
|
|
|
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
|
|
|
|
Trigger: "config-get",
|
|
|
|
|
Args: []string{appName, "DOKKU_IMAGE"},
|
|
|
|
|
})
|
|
|
|
|
if dokkuImage := results.StdoutContents(); dokkuImage != "" {
|
2021-01-23 18:17:40 -05:00
|
|
|
common.LogWarn("Deprecated: use buildpacks:set-property instead of specifying DOKKU_IMAGE environment variable")
|
2021-01-17 23:20:16 -05:00
|
|
|
return dokkuImage
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return os.Getenv("DOKKU_IMAGE")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func reportGlobalStack(appName string) string {
|
|
|
|
|
return common.PropertyGetDefault("buildpacks", "--global", "stack", "")
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 23:56:10 -05:00
|
|
|
func reportList(appName string) string {
|
|
|
|
|
buildpacks, err := common.PropertyListGet("buildpacks", appName, "buildpacks")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return strings.Join(buildpacks, ",")
|
|
|
|
|
}
|
2021-01-17 23:20:16 -05:00
|
|
|
|
|
|
|
|
func reportStack(appName string) string {
|
|
|
|
|
return common.PropertyGetDefault("buildpacks", appName, "stack", "")
|
|
|
|
|
}
|