Make linter happy

This commit is contained in:
Benedikt Kulmann
2020-08-24 16:56:06 +02:00
parent 27b7431f70
commit 16b9042b4b
4 changed files with 9 additions and 8 deletions

View File

@@ -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)
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -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,