From 33f216f38697e2ec4c5a35a6b77d295b9b8c1f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Fri, 20 Jun 2025 20:43:03 +0300 Subject: [PATCH 1/2] read key from env if provided --- v2/pkg/passive/sources.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/v2/pkg/passive/sources.go b/v2/pkg/passive/sources.go index e776c572a..94ab860c6 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,16 @@ func New(sourceNames, excludedSourceNames []string, useAllSources, useSourcesSup } } + // TODO: Consider refactoring this to avoid potential duplication issues + for _, source := range sources { + if source.NeedsKey() { + fmt.Println(source.Name()) + 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)} From 90178175604ea5ac665188c379cdb8b0328003b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Fri, 20 Jun 2025 20:51:55 +0300 Subject: [PATCH 2/2] remove debug code --- v2/pkg/passive/sources.go | 1 - 1 file changed, 1 deletion(-) diff --git a/v2/pkg/passive/sources.go b/v2/pkg/passive/sources.go index 94ab860c6..20013042f 100644 --- a/v2/pkg/passive/sources.go +++ b/v2/pkg/passive/sources.go @@ -173,7 +173,6 @@ func New(sourceNames, excludedSourceNames []string, useAllSources, useSourcesSup // TODO: Consider refactoring this to avoid potential duplication issues for _, source := range sources { if source.NeedsKey() { - fmt.Println(source.Name()) if apiKey := os.Getenv(fmt.Sprintf("%s_API_KEY", strings.ToUpper(source.Name()))); apiKey != "" { source.AddApiKeys([]string{apiKey}) }