mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: implement API key scopes database migration (#19861)
Added database migration for API key scopes. Fixes #19845
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/rbac/policy"
|
||||
)
|
||||
|
||||
func main() {
|
||||
seen := map[string]struct{}{}
|
||||
var vals []string
|
||||
for resource, def := range policy.RBACPermissions {
|
||||
if resource == policy.WildcardSymbol {
|
||||
continue
|
||||
}
|
||||
for action := range def.Actions {
|
||||
vals = append(vals, fmt.Sprintf("%s:%s", resource, action))
|
||||
}
|
||||
}
|
||||
sort.Strings(vals)
|
||||
for _, v := range vals {
|
||||
if _, ok := seen[v]; ok {
|
||||
continue
|
||||
}
|
||||
seen[v] = struct{}{}
|
||||
_, _ = fmt.Printf("ALTER TYPE api_key_scope ADD VALUE IF NOT EXISTS '%s';\n", v)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user