Skip to content

Commit

Permalink
fix: don't require debug level to print error details on failed loadi…
Browse files Browse the repository at this point in the history
…ng of provider metadata json
  • Loading branch information
mgoetzegb authored and koplas committed Jul 15, 2024
1 parent 51dc9b5 commit 1e531de
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
14 changes: 9 additions & 5 deletions cmd/csaf_aggregator/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,21 @@ func (w *worker) locateProviderMetadata(domain string) error {

lpmd := loader.Load(domain)

if w.processor.cfg.Verbose {
if !lpmd.Valid() {
for i := range lpmd.Messages {
w.log.Info(
w.log.Error(
"Loading provider-metadata.json",
"domain", domain,
"message", lpmd.Messages[i].Message)
}
}

if !lpmd.Valid() {
return fmt.Errorf("no valid provider-metadata.json found for '%s'", domain)
} else if w.processor.cfg.Verbose {
for i := range lpmd.Messages {
w.log.Debug(
"Loading provider-metadata.json",
"domain", domain,
"message", lpmd.Messages[i].Message)
}
}

w.metadataProvider = lpmd.Document
Expand Down
13 changes: 8 additions & 5 deletions cmd/csaf_downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,21 @@ func (d *downloader) download(ctx context.Context, domain string) error {

lpmd := loader.Load(domain)

if d.cfg.verbose() {
if !lpmd.Valid() {
for i := range lpmd.Messages {
slog.Error("Loading provider-metadata.json",
"domain", domain,
"message", lpmd.Messages[i].Message)
}
return fmt.Errorf("no valid provider-metadata.json found for '%s': ", domain)
} else if d.cfg.verbose() {
for i := range lpmd.Messages {
slog.Debug("Loading provider-metadata.json",
"domain", domain,
"message", lpmd.Messages[i].Message)
}
}

if !lpmd.Valid() {
return fmt.Errorf("no valid provider-metadata.json found for '%s'", domain)
}

base, err := url.Parse(lpmd.URL)
if err != nil {
return fmt.Errorf("invalid URL '%s': %v", lpmd.URL, err)
Expand Down

0 comments on commit 1e531de

Please sign in to comment.