From c586ca4d0e0d84f7ed97c6c6cc4a5abc1e5e463a Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Wed, 3 Aug 2022 14:50:33 +0200 Subject: [PATCH] Change `projectOrName()` to check COMPOSE_PROJECT_NAME env var Signed-off-by: Laura Brehm --- cmd/compose/compose.go | 4 ++++ pkg/e2e/fixtures/start-stop/other.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/compose/compose.go b/cmd/compose/compose.go index c15241415..cfa5154a1 100644 --- a/cmd/compose/compose.go +++ b/cmd/compose/compose.go @@ -142,6 +142,10 @@ func (o *projectOptions) projectOrName() (*types.Project, string, error) { if o.ProjectName == "" { p, err := o.toProject(nil) if err != nil { + envProjectName := os.Getenv("COMPOSE_PROJECT_NAME") + if envProjectName != "" { + return nil, envProjectName, nil + } return nil, "", err } project = p diff --git a/pkg/e2e/fixtures/start-stop/other.yaml b/pkg/e2e/fixtures/start-stop/other.yaml index c28cbd09b..587827261 100644 --- a/pkg/e2e/fixtures/start-stop/other.yaml +++ b/pkg/e2e/fixtures/start-stop/other.yaml @@ -2,4 +2,4 @@ services: a-different-one: image: nginx:alpine and-another-one: - image: nginx:alpine \ No newline at end of file + image: nginx:alpine