MCPcopy Index your code
hub / github.com/docker/cli / newConfigCommand

Function newConfigCommand

cli/command/stack/config.go:21–50  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

19}
20
21func 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
53func outputConfig(configFiles composetypes.ConfigDetails, skipInterpolation bool) (string, error) {

Callers 2

newStackCommandFunction · 0.70

Calls 4

getConfigDetailsFunction · 0.85
outputConfigFunction · 0.85
InMethod · 0.65
OutMethod · 0.65

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…