Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions mmv1/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewLoader(config Config) *Loader {
return l
}

func (l *Loader) LoadProducts() {
func (l *Loader) LoadProducts() *Loader {
if l.version == "" {
log.Printf("No version specified, assuming ga")
l.version = "ga"
Expand Down Expand Up @@ -92,6 +92,8 @@ func (l *Loader) LoadProducts() {
}

l.Products = l.batchLoadProducts(allProductFiles)

return l
}

func (l *Loader) batchLoadProducts(productNames []string) map[string]*api.Product {
Expand Down Expand Up @@ -318,9 +320,9 @@ func (l *Loader) loadResource(product *api.Product, baseResourcePath string, ove
return resource
}

func (l *Loader) AddExtraFields() error {
func (l *Loader) AddExtraFields() *Loader {
if l.Products == nil {
return errors.New("products have not been loaded into memory")
log.Fatalln("products have not been loaded into memory")
}

for _, product := range l.Products {
Expand All @@ -331,7 +333,7 @@ func (l *Loader) AddExtraFields() error {
}
}

return nil
return l
}

func (l *Loader) Validate() {
Expand Down
3 changes: 1 addition & 2 deletions mmv1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ func GenerateProducts(product, resource, providerName, version, outputPath, base
}

loader := loader.NewLoader(loader.Config{Version: version, BaseDirectory: baseDirectory, OverrideDirectory: overrideDirectory, Sysfs: ofs})
loader.LoadProducts()
loader.AddExtraFields()
loader.LoadProducts().AddExtraFields()
loader.Validate()
loadedProducts := loader.Products

Expand Down
Loading