@@ -322,32 +322,30 @@ func LoadConfigFiles(ctx context.Context, configFiles []string, workingDir strin
322322
323323// LoadWithContext reads a ConfigDetails and returns a fully loaded configuration as a compose-go Project
324324func LoadWithContext (ctx context.Context , configDetails types.ConfigDetails , options ... func (* Options )) (* types.Project , error ) {
325- opts := ToOptions (& configDetails , options )
326- dict , err := loadModelWithContext (ctx , & configDetails , opts )
325+ model , err := LoadLazyModel (ctx , configDetails , options ... )
327326 if err != nil {
328327 return nil , err
329328 }
330- return ModelToProject ( dict , opts , configDetails )
329+ return model . Resolve ( )
331330}
332331
333332// LoadModelWithContext reads a ConfigDetails and returns a fully loaded configuration as a yaml dictionary
334333func LoadModelWithContext (ctx context.Context , configDetails types.ConfigDetails , options ... func (* Options )) (map [string ]any , error ) {
335- opts := ToOptions (& configDetails , options )
336- return loadModelWithContext (ctx , & configDetails , opts )
337- }
338-
339- // LoadModelWithContext reads a ConfigDetails and returns a fully loaded configuration as a yaml dictionary
340- func loadModelWithContext (ctx context.Context , configDetails * types.ConfigDetails , opts * Options ) (map [string ]any , error ) {
341- if len (configDetails .ConfigFiles ) < 1 {
342- return nil , errors .New ("no compose file specified" )
334+ project , err := LoadWithContext (ctx , configDetails , options ... )
335+ if err != nil {
336+ return nil , err
343337 }
344-
345- err := projectName ( configDetails , opts )
338+ // Marshal the typed project back to a yaml dictionary for backward compatibility
339+ b , err := yaml . Marshal ( project )
346340 if err != nil {
347341 return nil , err
348342 }
349-
350- return load (ctx , * configDetails , opts , nil )
343+ var dict map [string ]any
344+ if err := yaml .Unmarshal (b , & dict ); err != nil {
345+ return nil , err
346+ }
347+ dict ["name" ] = project .Name
348+ return dict , nil
351349}
352350
353351func ToOptions (configDetails * types.ConfigDetails , options []func (* Options )) * Options {
0 commit comments