From d48cf24c4d40dca5cb33775da297026fbec2a22a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 11 Feb 2021 06:49:19 -0500 Subject: [PATCH] fix: unify IsImageHerokuishBased with shell version Really we should just spit this out into a bin and then have the shell version wrap the golang ones... --- plugins/common/docker.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/plugins/common/docker.go b/plugins/common/docker.go index ef759affc..fe9dfa4bd 100644 --- a/plugins/common/docker.go +++ b/plugins/common/docker.go @@ -274,7 +274,27 @@ func IsImageCnbBased(image string) bool { // IsImageHerokuishBased returns true if app image is based on herokuish func IsImageHerokuishBased(image string, appName string) bool { - output, err := DockerInspect(image, "{{range .Config.Env}}{{if eq . \"USER=herokuishuser\" }}{{println .}}{{end}}{{end}}") + if len(image) == 0 { + return false + } + + if IsImageCnbBased(image) { + return true + } + + dokkuAppUser := "" + if len(appName) != 0 { + b, err := PlugnTriggerOutput("config-get", []string{appName, "DOKKU_APP_USER"}...) + if err == nil { + dokkuAppUser = strings.TrimSpace(string(b)) + } + } + + if len(dokkuAppUser) == 0 { + dokkuAppUser = "herokuishuser" + } + + output, err := DockerInspect(image, fmt.Sprintf("{{range .Config.Env}}{{if eq . \"USER=%s\" }}{{println .}}{{end}}{{end}}", dokkuAppUser)) if err != nil { return false }