Skip to content

Commit

Permalink
fix: cleanup discover cmd (#50)
Browse files Browse the repository at this point in the history
Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
  • Loading branch information
rchincha authored Jul 22, 2023
1 parent 0a53e47 commit 1cfdda3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 2 additions & 0 deletions pkg/cli/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func DiscoverCmd() *cobra.Command {
log.Error().Err(err).Msg("discover failed")
os.Exit(1)
}

log.Info().Str("output", output).Msg("successfully discovered installed packages")
},
}

Expand Down
18 changes: 8 additions & 10 deletions pkg/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,23 @@ type Distro interface {

func InstalledPackages(doc *spdx.Document) error {
deberr := deb.InstalledPackages(doc)
if deberr != nil {
log.Error().Err(deberr).Msg("deb: unable to get installed packages")
if deberr == nil {
return nil
}

rpmerr := rpm.InstalledPackages(doc)
if rpmerr != nil {
log.Error().Err(rpmerr).Msg("rpm: unable to get installed packages")
if rpmerr == nil {
return nil
}

apkerr := apk.InstalledPackages(doc)
if apkerr != nil {
log.Error().Err(apkerr).Msg("apk: unable to get installed packages")
if apkerr == nil {
return nil
}

if deberr != nil && rpmerr != nil && apkerr != nil {
return errors.ErrNotFound
}
log.Error().Err(apkerr).Msg("unable to get installed packages")

return nil
return errors.ErrNotFound
}

func ParsePackage(input, author, organization, license, output string) error {
Expand Down

0 comments on commit 1cfdda3

Please # to comment.