diff --git a/v2/pkg/passive/sources.go b/v2/pkg/passive/sources.go index e776c572a..20013042f 100644 --- a/v2/pkg/passive/sources.go +++ b/v2/pkg/passive/sources.go @@ -1,6 +1,8 @@ package passive import ( + "fmt" + "os" "strings" "golang.org/x/exp/maps" @@ -168,6 +170,15 @@ func New(sourceNames, excludedSourceNames []string, useAllSources, useSourcesSup } } + // TODO: Consider refactoring this to avoid potential duplication issues + for _, source := range sources { + if source.NeedsKey() { + if apiKey := os.Getenv(fmt.Sprintf("%s_API_KEY", strings.ToUpper(source.Name()))); apiKey != "" { + source.AddApiKeys([]string{apiKey}) + } + } + } + // Create the agent, insert the sources and remove the excluded sources agent := &Agent{sources: maps.Values(sources)}