Skip to content

Commit

Permalink
implement filterlist for resource policy observation
Browse files Browse the repository at this point in the history
  • Loading branch information
stefnans committed Aug 9, 2024
1 parent 6ca4224 commit 3088e2e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/controller/cloudwatchlogs/resourcepolicy/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func SetupResourcePolicy(mgr ctrl.Manager, o controller.Options) error {

opts := []option{
func(e *external) {
e.filterList = filterList
e.preCreate = preCreate
e.preUpdate = preUpdate
e.preDelete = preDelete
Expand Down Expand Up @@ -91,3 +92,15 @@ func isUpToDate(_ context.Context, cr *svcapitypes.ResourcePolicy, obj *svcsdk.D
}
return false, "", nil
}

func filterList(cr *svcapitypes.ResourcePolicy, list *svcsdk.DescribeResourcePoliciesOutput) *svcsdk.DescribeResourcePoliciesOutput {
resp := &svcsdk.DescribeResourcePoliciesOutput{}

for _, resourcePolicy := range list.ResourcePolicies {
if pointer.StringValue(resourcePolicy.PolicyName) == meta.GetExternalName(cr) {
resp.ResourcePolicies = append(resp.ResourcePolicies, resourcePolicy)
break
}
}
return resp
}

0 comments on commit 3088e2e

Please sign in to comment.