Skip to content

Commit

Permalink
Merge pull request #5743 from mvo5/dont-panic-in-image
Browse files Browse the repository at this point in the history
image: handle errors when downloadedSnapsInfoForBootConfig has no data
  • Loading branch information
zyga committed Aug 31, 2018
2 parents cb747a6 + 923cf59 commit a2629ed
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,15 @@ func setBootvars(downloadedSnapsInfoForBootConfig map[string]*snap.Info, model *
bootvar := ""

info := downloadedSnapsInfoForBootConfig[fn]
if info == nil {
// this should never happen, if it does print some
// debug info
keys := make([]string, 0, len(downloadedSnapsInfoForBootConfig))
for k := range downloadedSnapsInfoForBootConfig {
keys = append(keys, k)
}
return fmt.Errorf("cannot get download info for snap %s, available infos: %v", fn, keys)
}
switch info.Type {
case snap.TypeOS, snap.TypeBase:
bootvar = "snap_core"
Expand Down

0 comments on commit a2629ed

Please sign in to comment.