From c2a7aa7563da8c8e82d4745aff13ebcbf8298506 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/engine/eval/eval.go b/internal/engine/eval/eval.go index 5e54ff0f2e..f3e98da552 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,9 +50,13 @@ 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 := rt.Def.Eval.GetPackageIntelligence() + if pie == nil { return nil, fmt.Errorf("rule type engine missing package_intelligence configuration") } + if pie.GetEndpoint() == "" { + pie.Endpoint = os.Getenv("MEDIATOR_UNSTABLE_PACKAGE_INTELLIGENCE_ENDPOINT") + } return package_intelligence.NewPackageIntelligenceEvaluator(e.GetPackageIntelligence(), cli) default: return nil, fmt.Errorf("unsupported rule type engine: %s", rt.Def.Eval.Type)