Skip to content

Commit

Permalink
config --xx don't need env_file being parsed
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Sep 21, 2023
1 parent 52a641b commit ab81db5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cmd/compose/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ type configOptions struct {
noConsistency bool
}

func (o *configOptions) ToProject(ctx context.Context, dockerCli command.Cli, services []string) (*types.Project, error) {
return o.ProjectOptions.ToProject(dockerCli, services,
func (o *configOptions) ToProject(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (*types.Project, error) {
po = append(po,
cli.WithInterpolation(!o.noInterpolate),
cli.WithResolvedPaths(!o.noResolvePath),
cli.WithNormalization(!o.noNormalize),
cli.WithConsistency(!o.noConsistency),
cli.WithDefaultProfiles(o.Profiles...),
cli.WithDiscardEnvFile,
cli.WithContext(ctx))
return o.ProjectOptions.ToProject(dockerCli, services, po...)
}

func configCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
Expand Down Expand Up @@ -154,7 +155,7 @@ func runConfig(ctx context.Context, dockerCli command.Cli, backend api.Service,
}

func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
project, err := opts.ToProject(ctx, dockerCli, nil)
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)

Check warning on line 158 in cmd/compose/config.go

View check run for this annotation

Codecov / codecov/patch

cmd/compose/config.go#L158

Added line #L158 was not covered by tests
if err != nil {
return err
}
Expand All @@ -165,7 +166,7 @@ func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions)
}

func runVolumes(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
project, err := opts.ToProject(ctx, dockerCli, nil)
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)

Check warning on line 169 in cmd/compose/config.go

View check run for this annotation

Codecov / codecov/patch

cmd/compose/config.go#L169

Added line #L169 was not covered by tests
if err != nil {
return err
}
Expand All @@ -180,7 +181,7 @@ func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) err
if opts.hash != "*" {
services = append(services, strings.Split(opts.hash, ",")...)
}
project, err := opts.ToProject(ctx, dockerCli, nil)
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)

Check warning on line 184 in cmd/compose/config.go

View check run for this annotation

Codecov / codecov/patch

cmd/compose/config.go#L184

Added line #L184 was not covered by tests
if err != nil {
return err
}
Expand Down Expand Up @@ -209,7 +210,7 @@ func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) err

func runProfiles(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
set := map[string]struct{}{}
project, err := opts.ToProject(ctx, dockerCli, services)
project, err := opts.ToProject(ctx, dockerCli, services, cli.WithoutEnvironmentResolution)

Check warning on line 213 in cmd/compose/config.go

View check run for this annotation

Codecov / codecov/patch

cmd/compose/config.go#L213

Added line #L213 was not covered by tests
if err != nil {
return err
}
Expand All @@ -230,7 +231,7 @@ func runProfiles(ctx context.Context, dockerCli command.Cli, opts configOptions,
}

func runConfigImages(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
project, err := opts.ToProject(ctx, dockerCli, services)
project, err := opts.ToProject(ctx, dockerCli, services, cli.WithoutEnvironmentResolution)

Check warning on line 234 in cmd/compose/config.go

View check run for this annotation

Codecov / codecov/patch

cmd/compose/config.go#L234

Added line #L234 was not covered by tests
if err != nil {
return err
}
Expand Down

0 comments on commit ab81db5

Please sign in to comment.