policy.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package types
  2. type PermissionScope string
  3. const (
  4. UserScope PermissionScope = "user"
  5. ProjectScope PermissionScope = "project"
  6. ClusterScope PermissionScope = "cluster"
  7. NamespaceScope PermissionScope = "namespace"
  8. SettingsScope PermissionScope = "settings"
  9. ReleaseScope PermissionScope = "release"
  10. )
  11. type NameOrUInt struct {
  12. Name string `json:"name"`
  13. UInt uint `json:"uint"`
  14. }
  15. type PolicyDocument struct {
  16. Scope PermissionScope `json:"scope"`
  17. Resources []NameOrUInt `json:"resources"`
  18. Verbs []APIVerb `json:"verbs"`
  19. Children map[PermissionScope]*PolicyDocument `json:"children"`
  20. }
  21. type ScopeTree map[PermissionScope]ScopeTree
  22. /* ScopeHeirarchy describes the scope tree:
  23. Project
  24. / \
  25. Cluster Settings
  26. /
  27. Namespace
  28. |
  29. Release
  30. */
  31. var ScopeHeirarchy = ScopeTree{
  32. ProjectScope: {
  33. ClusterScope: {
  34. NamespaceScope: {
  35. ReleaseScope: {},
  36. },
  37. },
  38. SettingsScope: {},
  39. },
  40. }
  41. type Policy []*PolicyDocument