From d5c1de1cc16d699fac23fe69160cc374aa3fa903 Mon Sep 17 00:00:00 2001 From: Bruno Gomes Date: Thu, 6 Jun 2024 17:44:14 -0300 Subject: [PATCH] remove helper methods from policy data types --- acp/source_hub_client.go | 8 ++++---- acp/types.go | 10 ---------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/acp/source_hub_client.go b/acp/source_hub_client.go index eb61538963..2e18241103 100644 --- a/acp/source_hub_client.go +++ b/acp/source_hub_client.go @@ -162,8 +162,8 @@ func (a *sourceHubBridge) ValidateResourceExistsOnValidDPI( policy := maybePolicy.Value() // So far we validated that the policy exists, now lets validate that resource exists. - resourceResponse := policy.GetResourceByName(resourceName) - if resourceResponse == nil { + resourceResponse, ok := policy.Resources[resourceName] + if !ok { return newErrResourceDoesNotExistOnTargetPolicy(resourceName, policyID) } @@ -171,8 +171,8 @@ func (a *sourceHubBridge) ValidateResourceExistsOnValidDPI( // resource with the matching name, validate that all required permissions // for DPI actually exist on the target resource. for _, requiredPermission := range dpiRequiredPermissions { - permissionResponse := resourceResponse.GetPermissionByName(requiredPermission) - if permissionResponse == nil { + permissionResponse, ok := resourceResponse.Permissions[requiredPermission] + if !ok { return newErrResourceIsMissingRequiredPermission( resourceName, requiredPermission, diff --git a/acp/types.go b/acp/types.go index 5752f721d5..c7ffa17d73 100644 --- a/acp/types.go +++ b/acp/types.go @@ -30,11 +30,6 @@ type policy struct { Resources map[string]*resource } -// GetResourceByName returns a Resource with the given name or nil -func (p *policy) GetResourceByName(name string) *resource { - return p.Resources[name] -} - // resource is a data container carrying the necessary data // to verify whether it meets DPI requirements. type resource struct { @@ -42,11 +37,6 @@ type resource struct { Permissions map[string]*permission } -// GetPermissionByName returns a permission with the given name or nil -func (r *resource) GetPermissionByName(name string) *permission { - return r.Permissions[name] -} - // permission is a data container carrying the necessary data // to verify whether it meets DPI requirements. type permission struct {