MCPcopy
hub / github.com/docker/compose / runVariables

Function runVariables

cmd/compose/config.go:521–544  ·  view source on GitHub ↗
(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string)

Source from the content-addressed store, hash-verified

519}
520
521func runVariables(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
522 opts.noInterpolate = true
523 model, err := opts.ToModel(ctx, dockerCli, services, cli.WithoutEnvironmentResolution, cli.WithLoadOptions(loader.WithSkipValidation))
524 if err != nil {
525 return err
526 }
527
528 variables := template.ExtractVariables(model, template.DefaultPattern)
529
530 if opts.Format == "yaml" {
531 result, err := yaml.Marshal(variables)
532 if err != nil {
533 return err
534 }
535 fmt.Print(string(result))
536 return nil
537 }
538
539 return formatter.Print(variables, opts.Format, dockerCli.Out(), func(w io.Writer) {
540 for name, variable := range variables {
541 _, _ = fmt.Fprintf(w, "%s\t%t\t%s\t%s\n", name, variable.Required, variable.DefaultValue, variable.PresenceValue)
542 }
543 }, "NAME", "REQUIRED", "DEFAULT VALUE", "ALTERNATE VALUE")
544}
545
546func runEnvironment(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
547 backend, err := compose.NewComposeService(dockerCli)

Callers 2

configCommandFunction · 0.85

Calls 3

PrintFunction · 0.92
ToModelMethod · 0.45
OutMethod · 0.45