diff --git a/pkg/service/v0/service.go b/pkg/service/v0/service.go index 0bd66ec9f8..b8a4944023 100644 --- a/pkg/service/v0/service.go +++ b/pkg/service/v0/service.go @@ -313,7 +313,7 @@ func (g Service) getRoleIDs(c context.Context, accountUUID string) []string { g.logger.Err(err).Str("accountUUID", accountUUID).Msg("failed to list role assignments") return []string{} } - var roleIDs []string + roleIDs := make([]string, 0) for _, assignment := range rolesResponse.Assignments { roleIDs = append(roleIDs, assignment.RoleId) } diff --git a/pkg/store/filesystem/permissions.go b/pkg/store/filesystem/permissions.go index 45747ef507..8057130cf3 100644 --- a/pkg/store/filesystem/permissions.go +++ b/pkg/store/filesystem/permissions.go @@ -7,7 +7,7 @@ import ( // ListPermissionsByResource collects all permissions from the provided roleIDs that match the requested resource func (s Store) ListPermissionsByResource(resource *proto.Resource, roleIDs []string) ([]*proto.Permission, error) { - var records []*proto.Permission + records := make([]*proto.Permission, 0) for _, roleID := range roleIDs { role, err := s.ReadBundle(roleID) if err != nil { @@ -21,7 +21,7 @@ func (s Store) ListPermissionsByResource(resource *proto.Resource, roleIDs []str // extractPermissionsByResource collects all permissions from the provided role that match the requested resource func extractPermissionsByResource(resource *proto.Resource, role *proto.Bundle) []*proto.Permission { - var permissions []*proto.Permission + permissions := make([]*proto.Permission, 0) for _, setting := range role.Settings { if _, ok := setting.Value.(*proto.Setting_PermissionValue); ok { value := setting.Value.(*proto.Setting_PermissionValue).PermissionValue diff --git a/pkg/util/resource_helper.go b/pkg/util/resource_helper.go index 10892703d8..7aded40ba7 100644 --- a/pkg/util/resource_helper.go +++ b/pkg/util/resource_helper.go @@ -3,7 +3,7 @@ package util import "github.com/owncloud/ocis-settings/pkg/proto/v0" const ( - ResourceIdAll = "all" + ResourceIDAll = "all" ) // IsResourceMatched checks if the `example` resource is an exact match or a subset of `definition` @@ -11,5 +11,5 @@ func IsResourceMatched(definition, example *proto.Resource) bool { if definition.Type != example.Type { return false } - return definition.Id == ResourceIdAll || definition.Id == example.Id + return definition.Id == ResourceIDAll || definition.Id == example.Id } diff --git a/pkg/util/resource_helper_test.go b/pkg/util/resource_helper_test.go index 1cb560f28a..93423c39de 100644 --- a/pkg/util/resource_helper_test.go +++ b/pkg/util/resource_helper_test.go @@ -1,9 +1,10 @@ package util import ( + "testing" + "github.com/owncloud/ocis-settings/pkg/proto/v0" "gotest.tools/assert" - "testing" ) func TestIsResourceMatched(t *testing.T) { @@ -61,7 +62,7 @@ func TestIsResourceMatched(t *testing.T) { "same resource types with definition = ALL and without id in example is a match", &proto.Resource{ Type: proto.Resource_TYPE_USER, - Id: ResourceIdAll, + Id: ResourceIDAll, }, &proto.Resource{ Type: proto.Resource_TYPE_USER, @@ -72,7 +73,7 @@ func TestIsResourceMatched(t *testing.T) { "same resource types with definition.id = ALL and with some id in example is a match", &proto.Resource{ Type: proto.Resource_TYPE_USER, - Id: ResourceIdAll, + Id: ResourceIDAll, }, &proto.Resource{ Type: proto.Resource_TYPE_USER,