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

Method LoadProject

cli/options.go:467–487  ·  view source on GitHub ↗

LoadProject loads compose file according to options and bind to types.Project go structs

(ctx context.Context)

Source from the content-addressed store, hash-verified

465
466// LoadProject loads compose file according to options and bind to types.Project go structs
467func (o *ProjectOptions) LoadProject(ctx context.Context) (*types.Project, error) {
468 config, err := o.prepare(ctx)
469 if err != nil {
470 return nil, err
471 }
472
473 project, err := loader.LoadWithContext(ctx, types.ConfigDetails{
474 ConfigFiles: config.ConfigFiles,
475 WorkingDir: config.WorkingDir,
476 Environment: o.Environment,
477 }, o.loadOptions...)
478 if err != nil {
479 return nil, err
480 }
481
482 for _, config := range config.ConfigFiles {
483 project.ComposeFiles = append(project.ComposeFiles, config.Filename)
484 }
485
486 return project, nil
487}
488
489// LoadModel loads compose file according to options and returns a raw (yaml tree) model
490func (o *ProjectOptions) LoadModel(ctx context.Context) (map[string]any, error) {

Callers 2

ProjectFromOptionsFunction · 0.80

Calls 2

prepareMethod · 0.95
LoadWithContextFunction · 0.92

Tested by 1