Documentation
¶
Index ¶
- Constants
- Variables
- func DeleteRoleFromCache(roleId string)
- func FilterVars(variables []*TemplateVar) map[string]interface{}
- func ResolveVariables(srcString string, t *Template, space *Space, user *User, ...) (string, error)
- func RoleExists(roleId string) bool
- func SaveRoleToCache(role *Role)
- func SetRoleCache(roles []*Role)
- type AuditLogEntry
- type CSIVolume
- type CSIVolumeCapability
- type CSIVolumeMountOptions
- type CSIVolumes
- type Group
- type PermissionName
- type Quota
- type Role
- type Session
- type Space
- type SpaceVolume
- type Template
- type TemplateScheduleDays
- type TemplateVar
- type Token
- type Usage
- type User
- type Volume
- type VolumeDataMap
Constants ¶
View Source
const ( AuditActorSystem = "System" AuditActorTypeUser = "User" AuditActorTypeSystem = "System" )
Define actor types
View Source
const ( AuditEventSystemStart = "System Start" // Auth AuditEventAuthFailed = "Login Failed" AuditEventAuthOk = "Login Success" // Groups AuditEventGroupCreate = "Group Create" AuditEventGroupUpdate = "Group Update" AuditEventGroupDelete = "Group Delete" // Roles AuditEventRoleCreate = "Role Create" AuditEventRoleUpdate = "Role Update" AuditEventRoleDelete = "Role Delete" // Spaces AuditEventSpaceCreate = "Space Create" AuditEventSpaceUpdate = "Space Update" AuditEventSpaceDelete = "Space Delete" AuditEventSpaceTransfer = "Space Transfer" // Templates AuditEventTemplateCreate = "Template Create" AuditEventTemplateUpdate = "Template Update" AuditEventTemplateDelete = "Template Delete" // Variables AuditEventVarCreate = "Variable Create" AuditEventVarUpdate = "Variable Update" AuditEventVarDelete = "Variable Delete" // Users AuditEventUserCreate = "User Create" AuditEventUserUpdate = "User Update" AuditEventUserDelete = "User Delete" // Volumes AuditEventVolumeCreate = "Volume Create" AuditEventVolumeUpdate = "Volume Update" AuditEventVolumeDelete = "Volume Delete" )
Define events
View Source
const ( PermissionManageUsers = iota // Can Manage Users PermissionManageTemplates // Can Manage Templates PermissionManageSpaces // Can Manage Spaces PermissionManageVolumes // Can Manage Volumes PermissionManageGroups // Can Manage Groups PermissionManageRoles // Can Manage Roles PermissionManageVariables // Can Manage Variables PermissionUseSpaces // Can Use Spaces PermissionUseTunnels // Can Use Tunnels PermissionViewAuditLogs // Can View Audit Logs PermissionTransferSpaces // Can Transfer Spaces )
Permissions
View Source
const (
RoleAdminUUID = "00000000-0000-0000-0000-000000000000"
)
Roles
View Source
const WEBUI_SESSION_COOKIE = "__KNOT_WEBUI_SESSION"
Variables ¶
View Source
var PermissionNames = []PermissionName{ {PermissionUseTunnels, "Can Use Tunnels"}, {PermissionManageSpaces, "Manage Spaces"}, {PermissionUseSpaces, "Can Use Spaces"}, {PermissionTransferSpaces, "Can Transfer Spaces"}, {PermissionShareSpaces, "Can Share Spaces"}, {PermissionManageTemplates, "Manage Templates"}, {PermissionManageVariables, "Manage Variables"}, {PermissionManageVolumes, "Manage Volumes"}, {PermissionManageGroups, "Manage Groups"}, {PermissionManageRoles, "Manage Roles"}, {PermissionManageUsers, "Manage Users"}, {PermissionViewAuditLogs, "View Audit Logs"}, }
Functions ¶
func DeleteRoleFromCache ¶ added in v0.12.0
func DeleteRoleFromCache(roleId string)
func FilterVars ¶ added in v0.10.0
func FilterVars(variables []*TemplateVar) map[string]interface{}
func ResolveVariables ¶
func ResolveVariables(srcString string, t *Template, space *Space, user *User, variables *map[string]interface{}) (string, error)
Parse an input string and resolve knot variables
func RoleExists ¶
func SaveRoleToCache ¶ added in v0.12.0
func SaveRoleToCache(role *Role)
func SetRoleCache ¶ added in v0.12.0
func SetRoleCache(roles []*Role)
Types ¶
type AuditLogEntry ¶ added in v0.12.9
type AuditLogEntry struct {
Id int64 `json:"audit_log_id" db:"audit_log_id,pk"`
Actor string `json:"actor" db:"actor"`
ActorType string `json:"actor_type" db:"actor_type"`
Event string `json:"event" db:"event"`
When time.Time `json:"created_at" db:"created_at"`
Details string `json:"details" db:"details"`
Properties map[string]interface{} `json:"properties" db:"properties,json"`
}
func NewAuditLogEntry ¶ added in v0.12.9
func NewAuditLogEntry(actor, actorType, event, details string, properties *map[string]interface{}) *AuditLogEntry
type CSIVolume ¶
type CSIVolume struct {
Id string `yaml:"id" json:"ID"`
Name string `yaml:"name" json:"Name"`
Namespace string `yaml:"namespace" json:"Namespace"`
PuluginId string `yaml:"plugin_id" json:"PluginID"`
Type string `yaml:"type" json:"Type"`
MountOptions CSIVolumeMountOptions `yaml:"mount_options" json:"MountOptions"`
CapacityMin interface{} `yaml:"capacity_min,omitempty" json:"RequestedCapacityMin,omitempty"`
CapacityMax interface{} `yaml:"capacity_max,omitempty" json:"RequestedCapacityMax,omitempty"`
Capabilities []CSIVolumeCapability `yaml:"capabilities,omitempty" json:"RequestedCapabilities,omitempty"`
Secrets map[string]string `yaml:"secrets,omitempty" json:"Secrets,omitempty"`
Parameters map[string]string `yaml:"parameters,omitempty" json:"Parameters,omitempty"`
}
type CSIVolumeCapability ¶
type CSIVolumeMountOptions ¶
type CSIVolumes ¶
type CSIVolumes struct {
Volumes []CSIVolume `yaml:"volumes" json:"Volumes"`
}
func LoadVolumesFromYaml ¶
type Group ¶
type Group struct {
Id string `json:"group_id" db:"group_id,pk"`
Name string `json:"name" db:"name"`
MaxSpaces uint32 `json:"max_spaces" db:"max_spaces"`
ComputeUnits uint32 `json:"compute_units" db:"compute_units"`
StorageUnits uint32 `json:"storage_units" db:"storage_units"`
MaxTunnels uint32 `json:"max_tunnels" db:"max_tunnels"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Group object
type PermissionName ¶ added in v0.12.0
type Role ¶ added in v0.12.0
type Role struct {
Id string `json:"role_id" db:"role_id,pk"`
Name string `json:"name" db:"name"`
Permissions []uint16 `json:"permissions" db:"permissions,json"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Role
func GetRoleFromCache ¶ added in v0.12.0
func GetRolesFromCache ¶ added in v0.12.0
func GetRolesFromCache() []*Role
type Session ¶
type Session struct {
Id string `json:"session_id" db:"session_id,pk"`
Ip string `json:"ip" db:"ip"`
UserId string `json:"user_id" db:"user_id"`
RemoteSessionId string `json:"remote_session_id" db:"remote_session_id"`
UserAgent string `json:"user_agent" db:"user_agent"`
ExpiresAfter time.Time `json:"expires_after" db:"expires_after"`
}
Session object
type Space ¶
type Space struct {
Id string `json:"space_id" db:"space_id,pk"`
ParentSpaceId string `json:"parent_space_id" db:"parent_space_id"`
UserId string `json:"user_id" db:"user_id"`
TemplateId string `json:"template_id" db:"template_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
Location string `json:"location" db:"location"`
Shell string `json:"shell" db:"shell"`
TemplateHash string `json:"template_hash" db:"template_hash"`
NomadNamespace string `json:"nomad_namespace" db:"nomad_namespace"`
ContainerId string `json:"container_id" db:"container_id"`
VolumeData VolumeDataMap `json:"volume_data" db:"volume_data"`
SSHHostSigner string `json:"ssh_host_signer" db:"ssh_host_signer"`
IsDeployed bool `json:"is_deployed" db:"is_deployed"`
IsPending bool `json:"is_pending" db:"is_pending"` // Flags if the space is pending a state change, starting or stopping
IsDeleting bool `json:"is_deleting" db:"is_deleting"`
AltNames []string `json:"alt_names"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Space object
type SpaceVolume ¶
func (*SpaceVolume) Scan ¶ added in v0.17.0
func (sv *SpaceVolume) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type Template ¶
type Template struct {
Id string `json:"template_id" db:"template_id,pk"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
Hash string `json:"hash" db:"hash"`
Job string `json:"job" db:"job"`
Volumes string `json:"volumes" db:"volumes"`
Groups []string `json:"groups" db:"groups,json"`
LocalContainer bool `json:"local_container" db:"local_container"`
IsManual bool `json:"is_manual" db:"is_manual"`
WithTerminal bool `json:"with_terminal" db:"with_terminal"`
WithVSCodeTunnel bool `json:"with_vscode_tunnel" db:"with_vscode_tunnel"`
WithCodeServer bool `json:"with_code_server" db:"with_code_server"`
WithSSH bool `json:"with_ssh" db:"with_ssh"`
ComputeUnits uint32 `json:"compute_units" db:"compute_units"`
StorageUnits uint32 `json:"storage_units" db:"storage_units"`
ScheduleEnabled bool `json:"schedule_enabled" db:"schedule_enabled"`
Schedule []TemplateScheduleDays `json:"schedule" db:"schedule,json"`
Locations []string `json:"locations" db:"locations,json"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Template object
func NewTemplate ¶
func NewTemplate(name string, description string, job string, volumes string, userId string, groups []string, localContainer bool, isManual bool, withTerminal bool, withVSCodeTunnel bool, withCodeServer bool, withSSH bool, computeUnits uint32, storageUnits uint32, scheduleEnabled bool, schedule *[]TemplateScheduleDays, locations []string) *Template
func (*Template) AllowedBySchedule ¶ added in v0.12.0
func (*Template) GetVolumes ¶
func (*Template) UpdateHash ¶
func (template *Template) UpdateHash()
type TemplateScheduleDays ¶ added in v0.12.0
type TemplateVar ¶
type TemplateVar struct {
Id string `json:"templatevar_id" db:"templatevar_id,pk"`
Name string `json:"name" db:"name"`
Location string `json:"location" db:"location"`
Value string `json:"value" db:"value"`
Protected bool `json:"protected" db:"protected"`
Local bool `json:"local" db:"local"`
Restricted bool `json:"restricted" db:"restricted"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Template Variable object
func NewTemplateVar ¶
func (*TemplateVar) DecryptSetValue ¶
func (templateVar *TemplateVar) DecryptSetValue(text string)
func (*TemplateVar) GetValueEncrypted ¶
func (templateVar *TemplateVar) GetValueEncrypted() string
type Token ¶
type Token struct {
Id string `json:"token_id" db:"token_id,pk"`
UserId string `json:"user_id" db:"user_id"`
SessionId string `json:"session_id" db:"session_id"`
Name string `json:"name" db:"name"`
ExpiresAfter time.Time `json:"expires_after" db:"expires_after"`
}
Session object
type User ¶
type User struct {
Id string `json:"user_id" db:"user_id,pk"`
Username string `json:"username" db:"username"`
Email string `json:"email" db:"email"`
Password string `json:"password" db:"password"`
TOTPSecret string `json:"totp_secret" db:"totp_secret"`
ServicePassword string `json:"service_password" db:"service_password"`
SSHPublicKey string `json:"ssh_public_key" db:"ssh_public_key"`
GitHubUsername string `json:"github_username" db:"github_username"`
Roles []string `json:"roles" db:"roles,json"`
Groups []string `json:"groups" db:"groups,json"`
Active bool `json:"active" db:"active"`
MaxSpaces uint32 `json:"max_spaces" db:"max_spaces"`
ComputeUnits uint32 `json:"compute_units" db:"compute_units"`
StorageUnits uint32 `json:"storage_units" db:"storage_units"`
MaxTunnels uint32 `json:"max_tunnels" db:"max_tunnels"`
PreferredShell string `json:"preferred_shell" db:"preferred_shell"`
Timezone string `json:"timezone" db:"timezone"`
LastLoginAt *time.Time `json:"last_login_at" db:"last_login_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
}
User object
func (*User) CheckPassword ¶
Check the password for the user
func (*User) HasAnyGroup ¶
func (*User) HasPermission ¶
func (*User) SetPassword ¶
Set the password for the user
type Volume ¶
type Volume struct {
Id string `json:"volume_id" db:"volume_id,pk"`
Name string `json:"name" db:"name"`
Location string `json:"location" db:"location"`
Definition string `json:"definition" db:"definition"`
Active bool `json:"active" db:"active"`
LocalContainer bool `json:"local_container" db:"local_container"`
CreatedUserId string `json:"created_user_id" db:"created_user_id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedUserId string `json:"updated_user_id" db:"updated_user_id"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Template object
type VolumeDataMap ¶ added in v0.17.0
type VolumeDataMap map[string]SpaceVolume
VolumeDataMap is a custom type that implements the sql.Scanner and driver.Valuer interfaces
func (*VolumeDataMap) Scan ¶ added in v0.17.0
func (v *VolumeDataMap) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
Click to show internal directories.
Click to hide internal directories.