fix container being recreated while config has not changed (#10540)

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De loof 2023-05-09 21:15:40 +02:00 committed by GitHub
parent f72d5d6099
commit 0c1a691fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -119,7 +119,7 @@ func (o *ProjectOptions) WithProject(fn ProjectFunc) func(cmd *cobra.Command, ar
// WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services // WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services
func (o *ProjectOptions) WithServices(fn ProjectServicesFunc) func(cmd *cobra.Command, args []string) error { func (o *ProjectOptions) WithServices(fn ProjectServicesFunc) func(cmd *cobra.Command, args []string) error {
return Adapt(func(ctx context.Context, args []string) error { return Adapt(func(ctx context.Context, args []string) error {
project, err := o.ToProject(args, cli.WithResolvedPaths(true)) project, err := o.ToProject(args, cli.WithResolvedPaths(true), cli.WithDiscardEnvFile)
if err != nil { if err != nil {
return err return err
} }
@ -143,7 +143,7 @@ func (o *ProjectOptions) projectOrName(services ...string) (*types.Project, stri
name := o.ProjectName name := o.ProjectName
var project *types.Project var project *types.Project
if len(o.ConfigPaths) > 0 || o.ProjectName == "" { if len(o.ConfigPaths) > 0 || o.ProjectName == "" {
p, err := o.ToProject(services) p, err := o.ToProject(services, cli.WithDiscardEnvFile)
if err != nil { if err != nil {
envProjectName := os.Getenv("COMPOSE_PROJECT_NAME") envProjectName := os.Getenv("COMPOSE_PROJECT_NAME")
if envProjectName != "" { if envProjectName != "" {

View File

@ -142,7 +142,7 @@ func runCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *co
return nil return nil
}), }),
RunE: Adapt(func(ctx context.Context, args []string) error { RunE: Adapt(func(ctx context.Context, args []string) error {
project, err := p.ToProject([]string{opts.Service}, cgo.WithResolvedPaths(true)) project, err := p.ToProject([]string{opts.Service}, cgo.WithResolvedPaths(true), cgo.WithDiscardEnvFile)
if err != nil { if err != nil {
return err return err
} }