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

Function load

loader/loader.go:559–590  ·  view source on GitHub ↗
(ctx context.Context, configDetails types.ConfigDetails, opts *Options, loaded []string)

Source from the content-addressed store, hash-verified

557}
558
559func load(ctx context.Context, configDetails types.ConfigDetails, opts *Options, loaded []string) (map[string]interface{}, error) {
560 mainFile := configDetails.ConfigFiles[0].Filename
561 for _, f := range loaded {
562 if f == mainFile {
563 loaded = append(loaded, mainFile)
564 return nil, fmt.Errorf("include cycle detected:\n%s\n include %s", loaded[0], strings.Join(loaded[1:], "\n include "))
565 }
566 }
567
568 dict, err := loadYamlModel(ctx, configDetails, opts, &cycleTracker{}, nil)
569 if err != nil {
570 return nil, err
571 }
572
573 if len(dict) == 0 {
574 return nil, errors.New("empty compose file")
575 }
576
577 if !opts.SkipValidation && opts.projectName == "" {
578 return nil, errors.New("project name must not be empty")
579 }
580
581 if !opts.SkipNormalization {
582 dict["name"] = opts.projectName
583 dict, err = Normalize(dict, configDetails.Environment)
584 if err != nil {
585 return nil, err
586 }
587 }
588
589 return dict, nil
590}
591
592// ModelToProject binds a canonical yaml dict into compose-go structs
593func ModelToProject(dict map[string]interface{}, opts *Options, configDetails types.ConfigDetails) (*types.Project, error) {

Callers 1

loadModelWithContextFunction · 0.70

Calls 2

loadYamlModelFunction · 0.85
NormalizeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…