36 lines
1.2 KiB
Go Template
36 lines
1.2 KiB
Go Template
// Code generated by: go run ./scripts/typegen rbac scopenames; DO NOT EDIT.
|
|||
|
|
package rbac
|
||
|
|
|
||
|
|
// ScopeName constants generated from policy.RBACPermissions.
|
||
|
|
// These represent low-level "<resource>:<action>" scope names.
|
||
|
|
// Built-in non-low-level scopes like "all" and "application_connect" remain
|
||
|
|
// declared in code, not here, to avoid duplication.
|
||
|
|
|
||
|
|
const (
|
||
|
|
{{- range $def := . }}
|
||
|
|
{{- $Res := pascalCaseName $def.Type }}
|
||
|
|
{{- range $act := actionsOf $def }}
|
||
|
|
Scope{{$Res}}{{ pascalCaseName $act }} ScopeName = "{{ $def.Type }}:{{ $act }}"
|
||
|
|
{{- end }}
|
||
|
|
{{- end }}
|
||
|
|
)
|
||
|
|
|
||
|
|
// Valid reports whether the ScopeName matches one of the known scope values.
|
||
|
|
// This includes both builtin scope names and generated low-level scopes.
|
||
|
|
// Builtins are sourced from rbac.BuiltinScopeNames() at generation time to
|
||
|
|
// ensure changes in rbac/scopes.go remain in sync here.
|
||
|
|
func (e ScopeName) Valid() bool {
|
||
|
|
switch e {
|
||
|
|
case {{ allCaseList . }}:
|
||
|
|
return true
|
||
|
|
}
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
|
||
|
|
// AllScopeNameValues returns a slice containing all known scope values,
|
||
|
|
// including builtin and generated low-level scopes.
|
||
|
|
func AllScopeNameValues() []ScopeName {
|
||
|
|
return []ScopeName{
|
||
|
|
{{ allCaseList . }},
|
||
|
|
}
|
||
|
|
}
|