@@ -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 }
@@ -353,7 +362,12 @@ func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions)
353362 return nil
354363 }
355364
356- project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
365+ backend , err := compose .NewComposeService (dockerCli )
366+ if err != nil {
367+ return err
368+ }
369+
370+ project , _ , err := opts .ProjectOptions .ToProject (ctx , dockerCli , backend , nil , cli .WithoutEnvironmentResolution )
357371 if err != nil {
358372 return err
359373 }
@@ -366,7 +380,12 @@ func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions)
366380}
367381
368382func runVolumes (ctx context.Context , dockerCli command.Cli , opts configOptions ) error {
369- project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
383+ backend , err := compose .NewComposeService (dockerCli )
384+ if err != nil {
385+ return err
386+ }
387+
388+ project , _ , err := opts .ProjectOptions .ToProject (ctx , dockerCli , backend , nil , cli .WithoutEnvironmentResolution )
370389 if err != nil {
371390 return err
372391 }
@@ -377,7 +396,12 @@ func runVolumes(ctx context.Context, dockerCli command.Cli, opts configOptions)
377396}
378397
379398func runNetworks (ctx context.Context , dockerCli command.Cli , opts configOptions ) error {
380- project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
399+ backend , err := compose .NewComposeService (dockerCli )
400+ if err != nil {
401+ return err
402+ }
403+
404+ project , _ , err := opts .ProjectOptions .ToProject (ctx , dockerCli , backend , nil , cli .WithoutEnvironmentResolution )
381405 if err != nil {
382406 return err
383407 }
@@ -388,7 +412,12 @@ func runNetworks(ctx context.Context, dockerCli command.Cli, opts configOptions)
388412}
389413
390414func runModels (ctx context.Context , dockerCli command.Cli , opts configOptions ) error {
391- project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
415+ backend , err := compose .NewComposeService (dockerCli )
416+ if err != nil {
417+ return err
418+ }
419+
420+ project , _ , err := opts .ProjectOptions .ToProject (ctx , dockerCli , backend , nil , cli .WithoutEnvironmentResolution )
392421 if err != nil {
393422 return err
394423 }
@@ -405,7 +434,13 @@ func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) err
405434 if opts .hash != "*" {
406435 services = append (services , strings .Split (opts .hash , "," )... )
407436 }
408- project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
437+
438+ backend , err := compose .NewComposeService (dockerCli )
439+ if err != nil {
440+ return err
441+ }
442+
443+ project , _ , err := opts .ProjectOptions .ToProject (ctx , dockerCli , backend , nil , cli .WithoutEnvironmentResolution )
409444 if err != nil {
410445 return err
411446 }
@@ -440,7 +475,13 @@ func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) err
440475
441476func runProfiles (ctx context.Context , dockerCli command.Cli , opts configOptions , services []string ) error {
442477 set := map [string ]struct {}{}
443- project , err := opts .ToProject (ctx , dockerCli , services , cli .WithoutEnvironmentResolution )
478+
479+ backend , err := compose .NewComposeService (dockerCli )
480+ if err != nil {
481+ return err
482+ }
483+
484+ project , err := opts .ToProject (ctx , dockerCli , backend , services )
444485 if err != nil {
445486 return err
446487 }
@@ -461,7 +502,12 @@ func runProfiles(ctx context.Context, dockerCli command.Cli, opts configOptions,
461502}
462503
463504func runConfigImages (ctx context.Context , dockerCli command.Cli , opts configOptions , services []string ) error {
464- project , err := opts .ToProject (ctx , dockerCli , services , cli .WithoutEnvironmentResolution )
505+ backend , err := compose .NewComposeService (dockerCli )
506+ if err != nil {
507+ return err
508+ }
509+
510+ project , err := opts .ToProject (ctx , dockerCli , backend , services )
465511 if err != nil {
466512 return err
467513 }
@@ -498,7 +544,12 @@ func runVariables(ctx context.Context, dockerCli command.Cli, opts configOptions
498544}
499545
500546func runEnvironment (ctx context.Context , dockerCli command.Cli , opts configOptions , services []string ) error {
501- project , err := opts .ToProject (ctx , dockerCli , services )
547+ backend , err := compose .NewComposeService (dockerCli )
548+ if err != nil {
549+ return err
550+ }
551+
552+ project , err := opts .ToProject (ctx , dockerCli , backend , services )
502553 if err != nil {
503554 return err
504555 }
0 commit comments