bootloader/bootloader.go: refactor ForGadget slightly

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
This commit is contained in:
Ian Johnson
2020-11-19 15:27:16 -06:00
parent e4ab1c5ca9
commit 072b8847eb

View File

@@ -366,12 +366,11 @@ func ForGadget(gadgetDir, rootDir string, opts *Options) (Bootloader, error) {
if forcedBootloader != nil || forcedError != nil {
return forcedBootloader, forcedError
}
for _, blNew := range bootloaders {
bl := blNew(rootDir, opts)
markerConf := filepath.Join(gadgetDir, bl.Name()+".conf")
for name, blNew := range bootloaders {
markerConf := filepath.Join(gadgetDir, name+".conf")
// do we have a marker file?
if osutil.FileExists(markerConf) {
return bl, nil
return blNew(rootDir, opts), nil
}
}
return nil, ErrBootloader