Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Lobkov <[email protected]>
  • Loading branch information
lobkovilya committed Jan 16, 2025
1 parent 4dfa80c commit 00cbfa3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/plugins/policies/core/rules/outbound/resourcerules.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,14 @@ func buildRules[T interface {
resolvedItems = append(resolvedItems, resolveTargetRef(item, reader)...)
}

indexResources := func() map[core_model.TypedResourceIdentifier]core_model.Resource {
index := map[core_model.TypedResourceIdentifier]core_model.Resource{}
for _, i := range resolvedItems {
index[UniqueKey(i.resource, i.sectionName())] = i.resource
}
return index
indexed := map[core_model.TypedResourceIdentifier]core_model.Resource{}
for _, i := range resolvedItems {
indexed[UniqueKey(i.resource, i.sectionName())] = i.resource
}

// we could've built ResourceRule for all resources in the cluster, but we only need to build rules for resources
// that are part of the policy to reduce the size of the ResourceRules
for uri, resource := range indexResources() {
for uri, resource := range indexed {
// take only policy items that have isRelevant conf for the resource
var relevant []T
for _, policyItem := range resolvedItems {
Expand Down

0 comments on commit 00cbfa3

Please sign in to comment.