mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -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,
|
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 {
|
switch format {
|
||||||
case "json", "yaml":
|
case "json", "yaml":
|
||||||
if len(foundAssets) == 0 {
|
|
||||||
log.Info().Msg("Scan complete. No responsive assets were found.")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var output []byte
|
var output []byte
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
|
@ -166,7 +170,6 @@ var ScanCmd = &cobra.Command{
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// if -o flag was used, write to file, if not print to console.
|
|
||||||
if outputPath != "" {
|
if outputPath != "" {
|
||||||
err := os.WriteFile(outputPath, output, 0644)
|
err := os.WriteFile(outputPath, output, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -179,24 +182,16 @@ var ScanCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
case "db":
|
case "db":
|
||||||
if len(foundAssets) > 0 && debug {
|
|
||||||
log.Info().Any("assets", foundAssets).Msgf("found assets from scan")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !disableCache && cachePath != "" {
|
if !disableCache && cachePath != "" {
|
||||||
err := os.MkdirAll(path.Dir(cachePath), 0755)
|
err := os.MkdirAll(path.Dir(cachePath), 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to make cache directory: %v", err)
|
log.Printf("failed to make cache directory: %v", err)
|
||||||
}
|
}
|
||||||
if len(foundAssets) > 0 {
|
err = sqlite.InsertScannedAssets(cachePath, foundAssets...)
|
||||||
err := sqlite.InsertScannedAssets(cachePath, foundAssets...)
|
if err != nil {
|
||||||
if err != nil {
|
log.Error().Err(err).Msg("failed to write scanned assets to cache")
|
||||||
log.Error().Err(err).Msg("failed to write scanned assets to cache")
|
} else if verbose {
|
||||||
} else if verbose {
|
log.Info().Msgf("Saved assets to cache: %s", cachePath)
|
||||||
log.Info().Msgf("Saved assets to cache: %s", cachePath)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.Warn().Msg("no assets found to save")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue