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

Function formatModel

cmd/compose/config.go:335–348  ·  view source on GitHub ↗
(model map[string]any, format string)

Source from the content-addressed store, hash-verified

333}
334
335func formatModel(model map[string]any, format string) (content []byte, err error) {
336 switch format {
337 case "json":
338 return json.MarshalIndent(model, "", " ")
339 case "yaml":
340 buf := bytes.NewBuffer([]byte{})
341 encoder := yaml.NewEncoder(buf)
342 encoder.SetIndent(2)
343 err = encoder.Encode(model)
344 return buf.Bytes(), err
345 default:
346 return nil, fmt.Errorf("unsupported format %q", format)
347 }
348}
349
350func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
351 if opts.noInterpolate {

Callers 1

runConfigNoInterpolateFunction · 0.85

Calls 1

BytesMethod · 0.80

Tested by

no test coverage detected