Skip to content

Commit

Permalink
Only store manyData once
Browse files Browse the repository at this point in the history
Only collect the policy data once for each source
group. Before this the data was duplicated for
each component.

https://issues.redhat.com/browse/EC-1027
  • Loading branch information
joejstuart committed Nov 25, 2024
1 parent e614d88 commit 29aab5a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/validate/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func validateImageCmd(validate imageValidationFunc) *cobra.Command {
close(jobs)

var components []applicationsnapshot.Component
var manyData [][]evaluator.Data
var evaluatorData [][]evaluator.Data
var manyPolicyInput [][]byte
var allErrors error = nil
for i := 0; i < numComponents; i++ {
Expand All @@ -410,7 +410,10 @@ func validateImageCmd(validate imageValidationFunc) *cobra.Command {
allErrors = errors.Join(allErrors, e)
} else {
components = append(components, r.component)
manyData = append(manyData, r.data)
// evaluator data is duplicated per component, so only collect it once.
if len(evaluatorData) == 0 {
evaluatorData = append(evaluatorData, r.data)
}
manyPolicyInput = append(manyPolicyInput, r.policyInput)
}
}
Expand All @@ -428,7 +431,7 @@ func validateImageCmd(validate imageValidationFunc) *cobra.Command {
data.output = append(data.output, fmt.Sprintf("%s=%s", applicationsnapshot.JSON, data.outputFile))
}

report, err := applicationsnapshot.NewReport(data.snapshot, components, data.policy, manyData, manyPolicyInput, showSuccesses)
report, err := applicationsnapshot.NewReport(data.snapshot, components, data.policy, evaluatorData, manyPolicyInput, showSuccesses)
if err != nil {
return err
}
Expand Down

0 comments on commit 29aab5a

Please sign in to comment.