Skip to content

Commit 1a514b0

Browse files
authoredApr 2, 2020
Merge pull request operator-framework#248 from njhale/fix-panic
Fix panic in registry add
2 parents aa1652d + 73d3eb2 commit 1a514b0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎pkg/registry/populator.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (i *DirectoryPopulator) Populate() error {
4444
// manifests of the bundle should be loaded into the database.
4545
annotationsFile := &AnnotationsFile{}
4646
for _, f := range files {
47-
err = decodeFile(filepath.Join(metadata, f.Name()), err)
47+
err = decodeFile(filepath.Join(metadata, f.Name()), annotationsFile)
4848
if err != nil || *annotationsFile == (AnnotationsFile{}) {
4949
continue
5050
}
@@ -126,7 +126,9 @@ func loadBundle(csvName string, dir string) (*Bundle, error) {
126126
return nil, err
127127
}
128128

129-
bundle := &Bundle{}
129+
bundle := &Bundle{
130+
Name: csvName,
131+
}
130132
for _, f := range files {
131133
log = log.WithField("file", f.Name())
132134
if f.IsDir() {
@@ -239,6 +241,10 @@ func translateAnnotationsIntoPackage(annotations *AnnotationsFile, csv *ClusterS
239241

240242
// decodeFile decodes the file at a path into the given interface.
241243
func decodeFile(path string, into interface{}) error {
244+
if into == nil {
245+
panic("programmer error: decode destination must be instantiated before decode")
246+
}
247+
242248
fileReader, err := os.Open(path)
243249
if err != nil {
244250
return fmt.Errorf("unable to read file %s: %s", path, err)

0 commit comments

Comments
 (0)
Please sign in to comment.