fix: l10n make path, validation context key type and available role env
This commit is contained in:
@@ -45,7 +45,7 @@ l10n-push:
|
||||
|
||||
.PHONY: l10n-read
|
||||
l10n-read: $(GO_XGETTEXT)
|
||||
go-xgettext -o $(OUTPUT_DIR)/graph.pot --keyword=l10n.Template --add-comments -s pkg/service/v0/spacetemplates.go -s pkg/unifiedrole/unifiedrole.go
|
||||
go-xgettext -o $(OUTPUT_DIR)/graph.pot --keyword=l10n.Template --add-comments -s pkg/service/v0/spacetemplates.go -s pkg/unifiedrole/roles.go
|
||||
|
||||
.PHONY: l10n-write
|
||||
l10n-write:
|
||||
|
||||
@@ -2,5 +2,5 @@ package config
|
||||
|
||||
// UnifiedRoles contains all settings related to unified roles.
|
||||
type UnifiedRoles struct {
|
||||
AvailableRoles []string `yaml:"available_roles" env:"UNIFIED_ROLES_AVAILABLE_ROLES" desc:"A list of roles that are available for assignment." introductionVersion:"%%NEXT%%"`
|
||||
AvailableRoles []string `yaml:"available_roles" env:"GRAPH_AVAILABLE_ROLES" desc:"A list of roles that are available for assignment." introductionVersion:"%%NEXT%%"`
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@ import (
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/unifiedrole"
|
||||
)
|
||||
|
||||
var (
|
||||
_contextRoleIDsValueKey = "roleFilterIDs"
|
||||
type contextKey int
|
||||
|
||||
const (
|
||||
ContextKeyRoleIDsValueKey contextKey = iota
|
||||
)
|
||||
|
||||
// initLibregraph initializes libregraph validation
|
||||
@@ -88,7 +90,7 @@ func rolesAndActions(ctx context.Context, sl validator.StructLevel, roles, actio
|
||||
var availableActions []string
|
||||
var definitions []*libregraph.UnifiedRoleDefinition
|
||||
|
||||
switch roles, ok := ctx.Value(_contextRoleIDsValueKey).([]string); {
|
||||
switch roles, ok := ctx.Value(ContextKeyRoleIDsValueKey).([]string); {
|
||||
case ok:
|
||||
definitions = unifiedrole.GetRoles(unifiedrole.RoleFilterIDs(roles...))
|
||||
default:
|
||||
@@ -133,5 +135,5 @@ func rolesAndActions(ctx context.Context, sl validator.StructLevel, roles, actio
|
||||
|
||||
// ContextWithAllowedRoleIDs returns a new context which includes the allowed role IDs.
|
||||
func ContextWithAllowedRoleIDs(ctx context.Context, rolesIds []string) context.Context {
|
||||
return context.WithValue(ctx, _contextRoleIDsValueKey, rolesIds)
|
||||
return context.WithValue(ctx, ContextKeyRoleIDsValueKey, rolesIds)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user