@@ -61,26 +61,30 @@ type configOptions struct {
6161 lockImageDigests bool
6262}
6363
64- func (o * configOptions ) ToProject (ctx context.Context , dockerCli command.Cli , services []string , po ... cli.ProjectOptionsFn ) (* types.Project , error ) {
65- po = append (po , o .ToProjectOptions ()... )
66- project , _ , err := o .ProjectOptions .ToProject (ctx , dockerCli , services , po ... )
64+ func (o * configOptions ) ToProject (ctx context.Context , dockerCli command.Cli , backend api.Compose , services []string ) (* types.Project , error ) {
65+ project , _ , err := o .ProjectOptions .ToProject (ctx , dockerCli , backend , services , o .toProjectOptionsFns ()... )
6766 return project , err
6867}
6968
7069func (o * configOptions ) ToModel (ctx context.Context , dockerCli command.Cli , services []string , po ... cli.ProjectOptionsFn ) (map [string ]any , error ) {
71- po = append (po , o .ToProjectOptions ()... )
70+ po = append (po , o .toProjectOptionsFns ()... )
7271 return o .ProjectOptions .ToModel (ctx , dockerCli , services , po ... )
7372}
7473
75- func (o * configOptions ) ToProjectOptions () []cli.ProjectOptionsFn {
76- return []cli.ProjectOptionsFn {
74+ // toProjectOptionsFns converts config options to cli.ProjectOptionsFn
75+ func (o * configOptions ) toProjectOptionsFns () []cli.ProjectOptionsFn {
76+ fns := []cli.ProjectOptionsFn {
7777 cli .WithInterpolation (! o .noInterpolate ),
7878 cli .WithResolvedPaths (! o .noResolvePath ),
7979 cli .WithNormalization (! o .noNormalize ),
8080 cli .WithConsistency (! o .noConsistency ),
8181 cli .WithDefaultProfiles (o .Profiles ... ),
8282 cli .WithDiscardEnvFile ,
8383 }
84+ if o .noResolveEnv {
85+ fns = append (fns , cli .WithoutEnvironmentResolution )
86+ }
87+ return fns
8488}
8589
8690func configCommand (p * ProjectOptions , dockerCli command.Cli ) * cobra.Command {
@@ -197,7 +201,12 @@ func runConfig(ctx context.Context, dockerCli command.Cli, opts configOptions, s
197201}
198202
199203func runConfigInterpolate (ctx context.Context , dockerCli command.Cli , opts configOptions , services []string ) ([]byte , error ) {
200- project , err := opts .ToProject (ctx , dockerCli , services )
204+ backend , err := compose .NewComposeService (dockerCli )
205+ if err != nil {
206+ return nil , err
207+ }
208+
209+ project , err := opts .ToProject (ctx , dockerCli , backend , services )
201210 if err != nil {
202211 return nil , err
203212 }
@@ -354,7 +363,12 @@ func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions)
354363 return nil
355364 }
356365
357- project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
366+ backend , err := compose .NewComposeService (dockerCli )
367+ if err != nil {
368+ return err
369+ }
370+
371+ project , _ , err := opts .ProjectOptions .ToProject (ctx , dockerCli , backend , nil , cli .WithoutEnvironmentResolution )
358372 if err != nil {
359373 return err
360374 }
@@ -367,7 +381,12 @@ func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions)
367381}
368382
369383func runVolumes (ctx context.Context , dockerCli command.Cli , opts configOptions ) error {
370- project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
384+ backend , err := compose .NewComposeService (dockerCli )
385+ if err != nil {
386+ return err
387+ }
388+
389+ project , _ , err := opts .ProjectOptions .ToProject (ctx , dockerCli , backend , nil , cli .WithoutEnvironmentResolution )
371390 if err != nil {
372391 return err
373392 }
@@ -378,7 +397,12 @@ func runVolumes(ctx context.Context, dockerCli command.Cli, opts configOptions)
378397}
379398
380399func runNetworks (ctx context.Context , dockerCli command.Cli , opts configOptions ) error {
381- project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
400+ backend , err := compose .NewComposeService (dockerCli )
401+ if err != nil {
402+ return err
403+ }
404+
405+ project , _ , err := opts .ProjectOptions .ToProject (ctx , dockerCli , backend , nil , cli .WithoutEnvironmentResolution )
382406 if err != nil {
383407 return err
384408 }
@@ -389,7 +413,12 @@ func runNetworks(ctx context.Context, dockerCli command.Cli, opts configOptions)
389413}
390414
391415func runModels (ctx context.Context , dockerCli command.Cli , opts configOptions ) error {
392- project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
416+ backend , err := compose .NewComposeService (dockerCli )
417+ if err != nil {
418+ return err
419+ }
420+
421+ project , _ , err := opts .ProjectOptions .ToProject (ctx , dockerCli , backend , nil , cli .WithoutEnvironmentResolution )
393422 if err != nil {
394423 return err
395424 }
@@ -406,7 +435,13 @@ func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) err
406435 if opts .hash != "*" {
407436 services = append (services , strings .Split (opts .hash , "," )... )
408437 }
409- project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
438+
439+ backend , err := compose .NewComposeService (dockerCli )
440+ if err != nil {
441+ return err
442+ }
443+
444+ project , _ , err := opts .ProjectOptions .ToProject (ctx , dockerCli , backend , nil , cli .WithoutEnvironmentResolution )
410445 if err != nil {
411446 return err
412447 }
@@ -441,7 +476,13 @@ func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) err
441476
442477func runProfiles (ctx context.Context , dockerCli command.Cli , opts configOptions , services []string ) error {
443478 set := map [string ]struct {}{}
444- project , err := opts .ToProject (ctx , dockerCli , services , cli .WithoutEnvironmentResolution )
479+
480+ backend , err := compose .NewComposeService (dockerCli )
481+ if err != nil {
482+ return err
483+ }
484+
485+ project , err := opts .ToProject (ctx , dockerCli , backend , services )
445486 if err != nil {
446487 return err
447488 }
@@ -462,7 +503,12 @@ func runProfiles(ctx context.Context, dockerCli command.Cli, opts configOptions,
462503}
463504
464505func runConfigImages (ctx context.Context , dockerCli command.Cli , opts configOptions , services []string ) error {
465- project , err := opts .ToProject (ctx , dockerCli , services , cli .WithoutEnvironmentResolution )
506+ backend , err := compose .NewComposeService (dockerCli )
507+ if err != nil {
508+ return err
509+ }
510+
511+ project , err := opts .ToProject (ctx , dockerCli , backend , services )
466512 if err != nil {
467513 return err
468514 }
@@ -499,7 +545,12 @@ func runVariables(ctx context.Context, dockerCli command.Cli, opts configOptions
499545}
500546
501547func runEnvironment (ctx context.Context , dockerCli command.Cli , opts configOptions , services []string ) error {
502- project , err := opts .ToProject (ctx , dockerCli , services )
548+ backend , err := compose .NewComposeService (dockerCli )
549+ if err != nil {
550+ return err
551+ }
552+
553+ project , err := opts .ToProject (ctx , dockerCli , backend , services )
503554 if err != nil {
504555 return err
505556 }
0 commit comments