From 086879ab52e9a83d85c14bb2b0e499bd19737450 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 30 Oct 2023 15:02:45 +0100 Subject: [PATCH] If the pr_package_intelligence_check doesn't specify an endpoint, use an environment variable --- internal/engine/eval/eval.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/engine/eval/eval.go b/internal/engine/eval/eval.go index 5e54ff0f2e..fb65ca20fd 100644 --- a/internal/engine/eval/eval.go +++ b/internal/engine/eval/eval.go @@ -19,6 +19,7 @@ package eval import ( "fmt" + "os" "github.com/stacklok/mediator/internal/engine/eval/jq" "github.com/stacklok/mediator/internal/engine/eval/package_intelligence" @@ -49,10 +50,14 @@ func NewRuleEvaluator(rt *pb.RuleType, cli *providers.ProviderBuilder) (engif.Ev case vulncheck.VulncheckEvalType: return vulncheck.NewVulncheckEvaluator(e.GetVulncheck(), cli) case package_intelligence.PiEvalType: - if rt.Def.Eval.GetPackageIntelligence() == nil { + pie := e.GetPackageIntelligence() + if pie == nil { return nil, fmt.Errorf("rule type engine missing package_intelligence configuration") } - return package_intelligence.NewPackageIntelligenceEvaluator(e.GetPackageIntelligence(), cli) + if pie.GetEndpoint() == "" { + pie.Endpoint = os.Getenv("MEDIATOR_UNSTABLE_PACKAGE_INTELLIGENCE_ENDPOINT") + } + return package_intelligence.NewPackageIntelligenceEvaluator(pie, cli) default: return nil, fmt.Errorf("unsupported rule type engine: %s", rt.Def.Eval.Type) }