Skip to content

Commit

Permalink
If the pr_package_intelligence_check doesn't specify an endpoint, use…
Browse files Browse the repository at this point in the history
… an environment variable
  • Loading branch information
jhrozek committed Oct 30, 2023
1 parent 50471f8 commit 086879a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/engine/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 086879a

Please sign in to comment.