Skip to content

Commit

Permalink
epss: added tests
Browse files Browse the repository at this point in the history
Signed-off-by: daynewlee <[email protected]>
  • Loading branch information
daynewlee committed Nov 13, 2024
1 parent e48e33a commit 4295ba3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions enricher/epss/epss.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,27 @@ func (e *Enricher) Configure(ctx context.Context, f driver.ConfigUnmarshaler, c
ctx = zlog.ContextWithValues(ctx, "component", "enricher/epss/Enricher/Configure")
var cfg Config
e.c = c

if err := f(&cfg); err != nil {
return err
}
if cfg.FeedRoot != nil && strings.HasSuffix(*cfg.FeedRoot, ".gz") {
e.feedPath = *cfg.FeedRoot

if cfg.FeedRoot != nil {
// Parse and verify the URL format
if _, err := url.Parse(*cfg.FeedRoot); err != nil {
return fmt.Errorf("invalid URL format for FeedRoot: %w", err)
}

// Check if the URL points to a .gz file
if strings.HasSuffix(*cfg.FeedRoot, ".gz") {
e.feedPath = *cfg.FeedRoot
} else {
e.sourceURL() // Fallback to the default source URL if not a .gz file
}
} else {
e.sourceURL()
}

return nil
}

Expand Down

0 comments on commit 4295ba3

Please sign in to comment.