fix(scan): kindness msg when no-cache err on dnf mod list (#1128)

This commit is contained in:
Kota Kanbe
2021-01-14 08:12:35 +09:00
committed by GitHub
parent b5506a1368
commit aa954dc84c

View File

@@ -710,7 +710,10 @@ func (o *redhatBase) detectEnabledDnfModules() ([]string, error) {
cmd := `dnf --cacheonly --color=never --quiet module list --enabled`
r := o.exec(util.PrependProxyEnv(cmd), noSudo)
if !r.isSuccess() {
return nil, xerrors.Errorf("Failed to dnf module list: %s, cmd: %s", r, cmd)
if strings.Contains(r.Stdout, "Cache-only enabled but no cache") {
return nil, xerrors.Errorf("sudo yum check-update to make local cache before scanning: %s", r)
}
return nil, xerrors.Errorf("Failed to dnf module list: %s", r)
}
return o.parseDnfModuleList(r.Stdout)
}