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 {