Skip to content

Commit

Permalink
Merge pull request #248 from njhale/fix-panic
Browse files Browse the repository at this point in the history
Fix panic in registry add
  • Loading branch information
openshift-merge-robot committed Apr 2, 2020
2 parents aa1652d + 73d3eb2 commit 1a514b0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/registry/populator.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (i *DirectoryPopulator) Populate() error {
// manifests of the bundle should be loaded into the database.
annotationsFile := &AnnotationsFile{}
for _, f := range files {
err = decodeFile(filepath.Join(metadata, f.Name()), err)
err = decodeFile(filepath.Join(metadata, f.Name()), annotationsFile)
if err != nil || *annotationsFile == (AnnotationsFile{}) {
continue
}
Expand Down Expand Up @@ -126,7 +126,9 @@ func loadBundle(csvName string, dir string) (*Bundle, error) {
return nil, err
}

bundle := &Bundle{}
bundle := &Bundle{
Name: csvName,
}
for _, f := range files {
log = log.WithField("file", f.Name())
if f.IsDir() {
Expand Down Expand Up @@ -239,6 +241,10 @@ func translateAnnotationsIntoPackage(annotations *AnnotationsFile, csv *ClusterS

// decodeFile decodes the file at a path into the given interface.
func decodeFile(path string, into interface{}) error {
if into == nil {
panic("programmer error: decode destination must be instantiated before decode")
}

fileReader, err := os.Open(path)
if err != nil {
return fmt.Errorf("unable to read file %s: %s", path, err)
Expand Down

0 comments on commit 1a514b0

Please sign in to comment.