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...
This commit is contained in:
Jose Diaz-Gonzalez
2021-02-11 06:49:19 -05:00
parent 5614475521
commit d48cf24c4d

View File

@@ -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
}