mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-19 19:17:02 -07:00
Pull length of assets check out, per David's feedback
Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
This commit is contained in:
parent
96931cd8a3
commit
117783d264
1 changed files with 14 additions and 19 deletions
33
cmd/scan.go
33
cmd/scan.go
|
|
@ -145,13 +145,17 @@ var ScanCmd = &cobra.Command{
|
|||
Include: include,
|
||||
})
|
||||
|
||||
if len(foundAssets) > 0 && debug {
|
||||
log.Info().Any("assets", foundAssets).Msgf("found assets from scan")
|
||||
}
|
||||
|
||||
if len(foundAssets) == 0 {
|
||||
log.Info().Msg("Scan complete. No responsive assets were found.")
|
||||
return
|
||||
}
|
||||
|
||||
switch format {
|
||||
case "json", "yaml":
|
||||
if len(foundAssets) == 0 {
|
||||
log.Info().Msg("Scan complete. No responsive assets were found.")
|
||||
return
|
||||
}
|
||||
|
||||
var output []byte
|
||||
var err error
|
||||
|
||||
|
|
@ -166,7 +170,6 @@ var ScanCmd = &cobra.Command{
|
|||
return
|
||||
}
|
||||
|
||||
// if -o flag was used, write to file, if not print to console.
|
||||
if outputPath != "" {
|
||||
err := os.WriteFile(outputPath, output, 0644)
|
||||
if err != nil {
|
||||
|
|
@ -179,24 +182,16 @@ var ScanCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
case "db":
|
||||
if len(foundAssets) > 0 && debug {
|
||||
log.Info().Any("assets", foundAssets).Msgf("found assets from scan")
|
||||
}
|
||||
|
||||
if !disableCache && cachePath != "" {
|
||||
err := os.MkdirAll(path.Dir(cachePath), 0755)
|
||||
if err != nil {
|
||||
log.Printf("failed to make cache directory: %v", err)
|
||||
}
|
||||
if len(foundAssets) > 0 {
|
||||
err := sqlite.InsertScannedAssets(cachePath, foundAssets...)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("failed to write scanned assets to cache")
|
||||
} else if verbose {
|
||||
log.Info().Msgf("Saved assets to cache: %s", cachePath)
|
||||
}
|
||||
} else {
|
||||
log.Warn().Msg("no assets found to save")
|
||||
err = sqlite.InsertScannedAssets(cachePath, foundAssets...)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("failed to write scanned assets to cache")
|
||||
} else if verbose {
|
||||
log.Info().Msgf("Saved assets to cache: %s", cachePath)
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue