Skip to content

Commit eba3ff8

Browse files
idsulikndeloof
authored andcommitted
fix(config): Print service names with --no-interpolate
Signed-off-by: Suleiman Dibirov <[email protected]>
1 parent 6313365 commit eba3ff8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cmd/compose/config.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,22 @@ func formatModel(model map[string]any, format string) (content []byte, err error
279279
}
280280

281281
func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
282+
if opts.noInterpolate {
283+
// we can't use ToProject, so the model we render here is only partially resolved
284+
data, err := opts.ToModel(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
285+
if err != nil {
286+
return err
287+
}
288+
289+
if _, ok := data["services"]; ok {
290+
for serviceName := range data["services"].(map[string]any) {
291+
_, _ = fmt.Fprintln(dockerCli.Out(), serviceName)
292+
}
293+
}
294+
295+
return nil
296+
}
297+
282298
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
283299
if err != nil {
284300
return err
@@ -287,6 +303,7 @@ func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions)
287303
_, _ = fmt.Fprintln(dockerCli.Out(), serviceName)
288304
return nil
289305
})
306+
290307
return err
291308
}
292309

0 commit comments

Comments
 (0)