MCPcopy Create free account
hub / github.com/compose-spec/compose-go / prepare

Method prepare

cli/options.go:500–536  ·  view source on GitHub ↗

prepare converts ProjectOptions into loader's types.ConfigDetails and configures default load options

(ctx context.Context)

Source from the content-addressed store, hash-verified

498
499// prepare converts ProjectOptions into loader's types.ConfigDetails and configures default load options
500func (o *ProjectOptions) prepare(ctx context.Context) (*types.ConfigDetails, error) {
501 defaultDir, err := o.GetWorkingDir()
502 if err != nil {
503 return &types.ConfigDetails{}, err
504 }
505
506 configDetails, err := o.ReadConfigFiles(ctx, defaultDir, o)
507 if err != nil {
508 return configDetails, err
509 }
510
511 isNamed := false
512 if o.Name == "" {
513 type named struct {
514 Name string `yaml:"name,omitempty"`
515 }
516 // if any of the compose file is named, this is equivalent to user passing --project-name
517 for _, cfg := range configDetails.ConfigFiles {
518 var n named
519 err = yaml.Unmarshal(cfg.Content, &n)
520 if err != nil {
521 return nil, err
522 }
523 if n.Name != "" {
524 isNamed = true
525 break
526 }
527 }
528 }
529
530 o.loadOptions = append(o.loadOptions,
531 withNamePrecedenceLoad(defaultDir, isNamed, o),
532 withConvertWindowsPaths(o),
533 withListeners(o))
534
535 return configDetails, nil
536}
537
538// ProjectFromOptions load a compose project based on command line options
539// Deprecated: use ProjectOptions.LoadProject or ProjectOptions.LoadModel

Callers 2

LoadProjectMethod · 0.95
LoadModelMethod · 0.95

Calls 5

GetWorkingDirMethod · 0.95
ReadConfigFilesMethod · 0.95
withNamePrecedenceLoadFunction · 0.85
withConvertWindowsPathsFunction · 0.85
withListenersFunction · 0.85

Tested by

no test coverage detected