(dockerCLI command.Cli)
| 19 | } |
| 20 | |
| 21 | func newConfigCommand(dockerCLI command.Cli) *cobra.Command { |
| 22 | var opts configOptions |
| 23 | |
| 24 | cmd := &cobra.Command{ |
| 25 | Use: "config [OPTIONS]", |
| 26 | Short: "Outputs the final config file, after doing merges and interpolations", |
| 27 | Args: cli.NoArgs, |
| 28 | RunE: func(cmd *cobra.Command, args []string) error { |
| 29 | configDetails, err := getConfigDetails(opts.composeFiles, dockerCLI.In()) |
| 30 | if err != nil { |
| 31 | return err |
| 32 | } |
| 33 | |
| 34 | cfg, err := outputConfig(configDetails, opts.skipInterpolation) |
| 35 | if err != nil { |
| 36 | return err |
| 37 | } |
| 38 | |
| 39 | _, err = fmt.Fprintf(dockerCLI.Out(), "%s", cfg) |
| 40 | return err |
| 41 | }, |
| 42 | ValidArgsFunction: cobra.NoFileCompletions, |
| 43 | DisableFlagsInUseLine: true, |
| 44 | } |
| 45 | |
| 46 | flags := cmd.Flags() |
| 47 | flags.StringSliceVarP(&opts.composeFiles, "compose-file", "c", []string{}, `Path to a Compose file, or "-" to read from stdin`) |
| 48 | flags.BoolVar(&opts.skipInterpolation, "skip-interpolation", false, "Skip interpolation and output only merged config") |
| 49 | return cmd |
| 50 | } |
| 51 | |
| 52 | // outputConfig returns the merged and interpolated config file |
| 53 | func outputConfig(configFiles composetypes.ConfigDetails, skipInterpolation bool) (string, error) { |
searching dependent graphs…