expectedFromRBAC returns the set of scope names the DB enum must support.
()
| 60 | |
| 61 | // expectedFromRBAC returns the set of scope names the DB enum must support. |
| 62 | func expectedFromRBAC() map[string]struct{} { |
| 63 | want := make(map[string]struct{}) |
| 64 | add := func(name string) { |
| 65 | if name == "" { |
| 66 | return |
| 67 | } |
| 68 | want[name] = struct{}{} |
| 69 | } |
| 70 | // Low-level <resource>:<action> and synthesized <resource>:* wildcards |
| 71 | for resource, def := range policy.RBACPermissions { |
| 72 | if resource == policy.WildcardSymbol { |
| 73 | // Ignore wildcard entry; it has no concrete <resource>:<action> pairs. |
| 74 | continue |
| 75 | } |
| 76 | add(resource + ":" + policy.WildcardSymbol) |
| 77 | for action := range def.Actions { |
| 78 | add(resource + ":" + string(action)) |
| 79 | } |
| 80 | } |
| 81 | // Composite coder:* names |
| 82 | for _, n := range rbac.CompositeScopeNames() { |
| 83 | add(n) |
| 84 | } |
| 85 | // Built-in coder-prefixed scopes such as coder:all |
| 86 | for _, n := range rbac.BuiltinScopeNames() { |
| 87 | s := string(n) |
| 88 | if !strings.Contains(s, ":") { |
| 89 | continue |
| 90 | } |
| 91 | add(s) |
| 92 | } |
| 93 | return want |
| 94 | } |
| 95 | |
| 96 | // enumValuesFromDump parses dump.sql and extracts all literals from the |
| 97 | // `CREATE TYPE api_key_scope AS ENUM (...)` block. |
no test coverage detected