restore support for COMPOSE_COMPATIBILITY

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2025-12-05 13:13:52 +01:00 committed by Nicolas De loof
parent 9fada6cc23
commit c0345e4f45
3 changed files with 23 additions and 2 deletions

View File

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

20
pkg/api/env.go Normal file
View File

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

View File

@ -28,6 +28,7 @@ import (
"github.com/docker/compose/v5/pkg/api" "github.com/docker/compose/v5/pkg/api"
"github.com/docker/compose/v5/pkg/remote" "github.com/docker/compose/v5/pkg/remote"
"github.com/docker/compose/v5/pkg/utils"
) )
// LoadProject implements api.Compose.LoadProject // 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 = "_" api.Separator = "_"
} }