Просмотр исходного кода

restore support for COMPOSE_COMPATIBILITY

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 3 недель назад
Родитель
Сommit
c0345e4f45
3 измененных файлов с 23 добавлено и 2 удалено
  1. 1 1
      cmd/compose/compose.go
  2. 20 0
      pkg/api/env.go
  3. 2 1
      pkg/compose/loader.go

+ 1 - 1
cmd/compose/compose.go

@@ -59,7 +59,7 @@ const (
 	// ComposeProjectName define the project name to be used, instead of guessing from parent directory
 	ComposeProjectName = "COMPOSE_PROJECT_NAME"
 	// ComposeCompatibility try to mimic compose v1 as much as possible
-	ComposeCompatibility = "COMPOSE_COMPATIBILITY"
+	ComposeCompatibility = api.ComposeCompatibility
 	// ComposeRemoveOrphans remove "orphaned" containers, i.e. containers tagged for current project but not declared as service
 	ComposeRemoveOrphans = "COMPOSE_REMOVE_ORPHANS"
 	// ComposeIgnoreOrphans ignore "orphaned" containers

+ 20 - 0
pkg/api/env.go

@@ -0,0 +1,20 @@
+/*
+   Copyright 2020 Docker Compose CLI authors
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+*/
+
+package api
+
+// ComposeCompatibility try to mimic compose v1 as much as possible
+const ComposeCompatibility = "COMPOSE_COMPATIBILITY"

+ 2 - 1
pkg/compose/loader.go

@@ -28,6 +28,7 @@ import (
 
 	"github.com/docker/compose/v5/pkg/api"
 	"github.com/docker/compose/v5/pkg/remote"
+	"github.com/docker/compose/v5/pkg/utils"
 )
 
 // LoadProject implements api.Compose.LoadProject
@@ -48,7 +49,7 @@ func (s *composeService) LoadProject(ctx context.Context, options api.ProjectLoa
 		}
 	}
 
-	if options.Compatibility {
+	if options.Compatibility || utils.StringToBool(projectOptions.Environment[api.ComposeCompatibility]) {
 		api.Separator = "_"
 	}