Skip to content

Commit

Permalink
fix(config): Print service names with --no-interpolate
Browse files Browse the repository at this point in the history
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
  • Loading branch information
idsulik authored and ndeloof committed Nov 11, 2024
1 parent 6313365 commit eba3ff8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/compose/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,22 @@ func formatModel(model map[string]any, format string) (content []byte, err error
}

func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
if opts.noInterpolate {
// we can't use ToProject, so the model we render here is only partially resolved
data, err := opts.ToModel(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}

if _, ok := data["services"]; ok {
for serviceName := range data["services"].(map[string]any) {
_, _ = fmt.Fprintln(dockerCli.Out(), serviceName)
}
}

return nil
}

project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
if err != nil {
return err
Expand All @@ -287,6 +303,7 @@ func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions)
_, _ = fmt.Fprintln(dockerCli.Out(), serviceName)
return nil
})

return err
}

Expand Down

0 comments on commit eba3ff8

Please sign in to comment.