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

Function loadYamlModel

loader/loader.go:399–439  ·  view source on GitHub ↗
(ctx context.Context, config types.ConfigDetails, opts *Options, ct *cycleTracker, included []string)

Source from the content-addressed store, hash-verified

397}
398
399func loadYamlModel(ctx context.Context, config types.ConfigDetails, opts *Options, ct *cycleTracker, included []string) (map[string]interface{}, error) {
400 var (
401 dict = map[string]interface{}{}
402 err error
403 )
404 workingDir, environment := config.WorkingDir, config.Environment
405
406 for _, file := range config.ConfigFiles {
407 dict, _, err = loadYamlFile(ctx, file, opts, workingDir, environment, ct, dict, included)
408 if err != nil {
409 return nil, err
410 }
411 }
412
413 if !opts.SkipDefaultValues {
414 dict, err = transform.SetDefaultValues(dict)
415 if err != nil {
416 return nil, err
417 }
418 }
419
420 if !opts.SkipValidation {
421 if err := validation.Validate(dict); err != nil {
422 return nil, err
423 }
424 }
425
426 if opts.ResolvePaths {
427 var remotes []paths.RemoteResource
428 for _, loader := range opts.RemoteResourceLoaders() {
429 remotes = append(remotes, loader.Accept)
430 }
431 err = paths.ResolveRelativePaths(dict, config.WorkingDir, remotes)
432 if err != nil {
433 return nil, err
434 }
435 }
436 ResolveEnvironment(dict, config.Environment)
437
438 return dict, nil
439}
440
441func loadYamlFile(ctx context.Context,
442 file types.ConfigFile,

Callers 4

ApplyIncludeFunction · 0.85
loadFunction · 0.85
TestParseYAMLFilesFunction · 0.85

Calls 6

SetDefaultValuesFunction · 0.92
ValidateFunction · 0.92
ResolveRelativePathsFunction · 0.92
loadYamlFileFunction · 0.85
ResolveEnvironmentFunction · 0.85
RemoteResourceLoadersMethod · 0.80

Tested by 2

TestParseYAMLFilesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…