-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Process include/exclude from policy source #1026
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1026 +/- ##
==========================================
+ Coverage 79.33% 85.19% +5.86%
==========================================
Files 58 66 +8
Lines 4969 5330 +361
==========================================
+ Hits 3942 4541 +599
+ Misses 1027 789 -238
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -199,13 +202,13 @@ func (r conftestRunner) Run(ctx context.Context, fileList []string) (result []Ou | |||
|
|||
// NewConftestEvaluator returns initialized conftestEvaluator implementing | |||
// Evaluator interface | |||
func NewConftestEvaluator(ctx context.Context, policySources []source.PolicySource, p policy.Policy) (Evaluator, error) { | |||
return NewConftestEvaluatorWithNamespace(ctx, policySources, p, nil) | |||
func NewConftestEvaluator(ctx context.Context, policySources []source.PolicySource, p policy.Policy, sc *ecc.SourceConfig) (Evaluator, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ok for now, but I want us to reconsider this function signature. It seems redundant to pass in both the Policy
and the PolicySource
since the PolicySource
is within the Policy
. This is done, of course, so the evaluator knows which source group to use. I don't think the abstraction is quite right here.
We may want to consider this function only taking these parameters:
ctx context.Context
obviouslysrc *ecc.Source
. This should include theSourceConfig
and enough information to build[]source.PolicySource
.effectiveTime time.Time
. This function doesn't need a wholePolicy
, just the effective time.
There's a wrinkle with this though. We still need something to combine the config from ecc.Source
with the "global" config Policy.Spec().Configuration
. That might be better off done prior to calling NewConftestEvaluator
though which would make this a non-issue.
Anyways, this is somewhat subjective so I didn't want to include in this PR. If there's some agreement here, I will make a follow up PR to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 to refactor the signature here, perhaps something as simple as this could work?
// NewConftestEvaluator create a Evaluator implemented via Conftest to evaluate the n-th policy source
func NewConftestEvaluator(ctx context.Context, p policy.Policy, n int) (Evaluator, error) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even:
// NewConftestEvaluators create a slice of Evaluator implementations via Conftest
func NewConftestEvaluators(ctx context.Context, p policy.Policy) ([]Evaluator, error) {
https://issues.redhat.com/browse/HACBS-2428 Signed-off-by: Luiz Carvalho <[email protected]>
https://issues.redhat.com/browse/HACBS-2428