diff --git a/pkg/upstream/stack/loader.go b/pkg/upstream/stack/loader.go index 8997d201..f0697c93 100644 --- a/pkg/upstream/stack/loader.go +++ b/pkg/upstream/stack/loader.go @@ -21,27 +21,30 @@ type LoadConf struct { func LoadCompose(conf LoadConf) (*composeGoTypes.Project, error) { // NOTE(d1): silence compose-go internal logger logrus.SetOutput(io.Discard) - if len(conf.ComposeFiles) == 0 { return nil, errors.New(i18n.G("LoadCompose: provide compose files")) } - newProjectOptions := []composeGoCli.ProjectOptionsFn{} - if len(conf.AppEnv) == 0 { - newProjectOptions = append(newProjectOptions, composeGoCli.WithInterpolation(false)) - } else { + hasEnvVariables := len(conf.AppEnv) > 0 + newProjectOptions := []composeGoCli.ProjectOptionsFn{ + composeGoCli.WithInterpolation(hasEnvVariables), + } + + if hasEnvVariables { var env []string for k, v := range conf.AppEnv { env = append(env, fmt.Sprintf("%s=%s", k, v)) } newProjectOptions = append(newProjectOptions, composeGoCli.WithEnv(env)) + stackName, ok := conf.AppEnv["STACK_NAME"] if ok && stackName != "" { newProjectOptions = append(newProjectOptions, composeGoCli.WithName(stackName)) } } - // this is needed for updating tags, because each file is loaded one by one + // this is needed for updating tags and labels, because each file is loaded one by one + // and the consistency check requires every loaded file to have an image with tag if conf.DisableConsistencyCheck { newProjectOptions = append(newProjectOptions, composeGoCli.WithConsistency(false)) } @@ -50,10 +53,5 @@ func LoadCompose(conf LoadConf) (*composeGoTypes.Project, error) { if err != nil { return nil, err } - project, err := projectOptions.LoadProject(context.Background()) - if err != nil { - return project, err - } - - return project, nil + return projectOptions.LoadProject(context.Background()) }