read key from env if provided (#1607)

* read key from env if provided

* remove debug code
This commit is contained in:
Dogan Can Bakir
2025-06-20 21:45:21 +03:00
committed by GitHub
parent a0be3ff3ee
commit 7f3f2c2d5f
+11
View File
@@ -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)}