Skip to content

Commit

Permalink
Read the Pi hostname from config instead of rule_type (#1313)
Browse files Browse the repository at this point in the history
* Don't specify the Pi server explicitly in rule_type, rely on config defaults

Fixes: #1276

* If the pr_package_intelligence_check doesn't specify an endpoint, use an environment variable
  • Loading branch information
jhrozek authored Oct 30, 2023
1 parent d74f618 commit fe4a950
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ def:
# Defines the configuration for evaluating data ingested against the given profile
eval:
type: package_intelligence
package_intelligence:
endpoint: https://staging.stacklok.dev/
package_intelligence: {}
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 fe4a950

Please sign in to comment.