84 lines
2.2 KiB
Go
84 lines
2.2 KiB
Go
package models
|
|
|
|
var RolesAvailableTypes = []string{"builtin", "all"}
|
|
|
|
var BUILTIN_ROLE_NAMES = []string{
|
|
"basic_user",
|
|
"cluster_admin",
|
|
"queue_admin",
|
|
}
|
|
|
|
var ROLE_SUPPORT_FILTERS = []string{
|
|
"role_name",
|
|
"action",
|
|
}
|
|
|
|
var ROLE_SUPPORT_SORT = []string{
|
|
"role_name",
|
|
"action",
|
|
}
|
|
|
|
var ROLE_DEFAULT_COLUMN = []string{
|
|
"role_name",
|
|
"action",
|
|
"domain_type",
|
|
"domain_values",
|
|
}
|
|
|
|
var JSONBRFields = []string{"domain_values"}
|
|
|
|
type RoleFields struct {
|
|
RoleName string `json:"role_name"`
|
|
}
|
|
type RoleInfo struct {
|
|
RoleName string `json:"role_name"`
|
|
Action string `json:"action"`
|
|
DomainType string `json:"domain_type"`
|
|
DomainValues Jsonb `json:"domain_values"`
|
|
}
|
|
|
|
type RolePermission struct {
|
|
Permission string `json:"permission_name" binding:"required"`
|
|
DomainType string `json:"domain_type" binding:"required"`
|
|
DomainValues []string `json:"domain_values"`
|
|
}
|
|
|
|
type CreateRoleRequest struct {
|
|
RoleName string `json:"role_name" binding:"required"`
|
|
RolePermissions []RolePermission `json:"permissions" binding:"required"`
|
|
}
|
|
|
|
const (
|
|
DomainTypeAll = "all"
|
|
DomainTypeSelf = "self"
|
|
DomainTypeCluster = "cluster"
|
|
DomainTypeJob = "job"
|
|
DomainTypeQueue = "queue"
|
|
DomainTypeHost = "host"
|
|
DomainTypeUser = "user"
|
|
DomainTypeFile = "file"
|
|
DomainTypeHostGroup = "hostgroup"
|
|
DomainTypeUserGroup = "usergroup"
|
|
DomainTypeResource = "resource"
|
|
DomainTypeSelfUG = "self_ug"
|
|
DomainTypeSelfHG = "self_hg"
|
|
DomainTypeRBAC = "rbac"
|
|
)
|
|
|
|
var SupportedDomainTypes = map[string][]string{
|
|
DomainTypeCluster: {DomainTypeAll},
|
|
DomainTypeJob: {DomainTypeAll, DomainTypeSelf, DomainTypeSelfUG},
|
|
DomainTypeQueue: {DomainTypeAll, DomainTypeQueue},
|
|
DomainTypeHost: {DomainTypeAll, DomainTypeHostGroup},
|
|
DomainTypeUser: {DomainTypeAll, DomainTypeSelf},
|
|
DomainTypeFile: {DomainTypeAll, DomainTypeSelf},
|
|
DomainTypeHostGroup: {DomainTypeAll, DomainTypeSelfHG, DomainTypeHostGroup},
|
|
DomainTypeUserGroup: {DomainTypeAll, DomainTypeSelfUG, DomainTypeUserGroup},
|
|
DomainTypeResource: {DomainTypeAll, DomainTypeSelf},
|
|
DomainTypeRBAC: {DomainTypeAll, DomainTypeSelf},
|
|
}
|
|
|
|
type RoleCreateResponse struct {
|
|
RoleName string `json:"role_name"`
|
|
Message string `json:"message"`
|
|
}
|