mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-28 11:18:24 -04:00
Make linter happy
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user