From 8d0ddb7097830c291b7c746d29427c30f4412834 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Wed, 15 May 2024 21:41:30 -0500 Subject: [PATCH] chore: cli interface for creating custom site roles --- scripts/rbacgen/codersdk.gotmpl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/rbacgen/codersdk.gotmpl b/scripts/rbacgen/codersdk.gotmpl index 1492eaf86c2bf..dff4e165b1df5 100644 --- a/scripts/rbacgen/codersdk.gotmpl +++ b/scripts/rbacgen/codersdk.gotmpl @@ -16,3 +16,15 @@ const ( {{ $element.Enum }} RBACAction = "{{ $element.Value }}" {{- end }} ) + +// RBACResourceActions is the mapping of resources to which actions are valid for +// said resource type. +var RBACResourceActions = map[RBACResource][]RBACAction{ + {{- range $element := . }} + Resource{{ pascalCaseName $element.FunctionName }}: []RBACAction{ + {{- range $actionValue, $_ := $element.Actions }} + {{- actionEnum $actionValue -}}, + {{- end -}} + }, + {{- end }} +}