models

package
v0.29.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelSession      string = "session"
	ChannelShell        string = "shell"
	ChannelPty          string = "pty"
	ChannelPortForward  string = "port-forward"
	ChannelSFTP         string = "sftp"
	ChannelSCP          string = "scp"
	ChannelExec         string = "exec"
	ChannelForwardAgent string = "forward-agent"
	ChannelSystemExec   string = "system-exec"
)
View Source
const (
	ChannelShortSh string = "sh"
	ChannelShortPt string = "pt"
	ChannelShortPf string = "pf"
	ChannelShortSf string = "sf"
	ChannelShortSc string = "sc"
	ChannelShortEx string = "ex"
	ChannelShortAf string = "af"
	ChannelShortSe string = "se"
)
View Source
const (
	AuthMethodPublicKey string = "publickey"
	AuthMethodPassword  string = "password"
)
View Source
const WORKSPACE_PORT = 2822 // port that workspace containers listen on for grpc connections

Variables

View Source
var ErrActiveSessionNotFound = errors.New("active session not found")
View Source
var ErrAlreadyOnboarded = errors.New("user already onboarded")
View Source
var ErrInvalidParameters = errors.New("invalid parameters")

ErrInvalidParameters is returned when the provided parameters are invalid

View Source
var ErrMethodNotSupported = errors.New("method not supported")
View Source
var ErrOnboardingPending = errors.New("onboarding pending")
View Source
var ErrSessionNotFound = errors.New("session not found")
View Source
var ErrUserIsNotValid = errors.New("user is not valid")
View Source
var ErrUserNotAllowedOnboard = errors.New("user not allowed to onboard")
View Source
var ErrUserNotFound = errors.New("user not found")
View Source
var ErrUserNotOnboarded = errors.New("user not onboarded")
View Source
var ErrUserTokenNotSupported = errors.New("user token not supported by provider")
View Source
var ErrWorkspaceNotFound = errors.New("workspace not found")

ErrWorkspaceNotFound is returned when a workspace is not found

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	ID         int64
	Username   string
	Name       string
	Scopes     []string
	ExpiresAt  *time.Time
	CreatedAt  time.Time
	LastUsedAt *time.Time
	IsActive   bool
}

AccessToken is a Personal Access Token (PAT) tied to a user. It carries an explicit scopes list that caps what actions the token may perform. The raw token value is never stored here; only the DB layer holds the hash.

type AppSpec

type AppSpec struct {
	Name              string        `yaml:"name" validate:"required_if=Enabled true"`
	Enabled           bool          `yaml:"enabled" default:"false"`
	Binary            string        `yaml:"binary" validate:"required_if=Enabled true"`
	VersionCmd        []string      `yaml:"versionCmd,omitempty"`
	VersionRegex      string        `yaml:"versionRegex,omitempty"`
	Install           string        `yaml:"install,omitempty"`
	Start             []string      `yaml:"start" validate:"required_if=Enabled true"`
	Listen            int           `yaml:"listen,omitempty"`
	RestartPolicy     string        `yaml:"restartPolicy,omitempty" validate:"oneof=always on-failure never"`
	MaxRestartBackoff time.Duration `yaml:"maxRestartBackoff,omitempty"`
	InstallAsRoot     bool          `yaml:"installAsRoot,omitempty" default:"false"`
	AutoStart         bool          `yaml:"autoStart,omitempty" default:"false"`
	Protocol          string        `yaml:"protocol,omitempty" validate:"omitempty,oneof=http https ws wss tcp udp"`
}

type Blueprint

type Blueprint struct {
	Metadata             BlueprintMetadata
	Name                 string                 `yaml:"name" validate:"required,min=1,max=40"`
	Description          string                 `yaml:"description,omitempty" validate:"max=500"`
	IsTemplate           bool                   `yaml:"isTemplate,omitempty" default:"false"`
	Splash               string                 `yaml:"splash,omitempty"`
	Template             string                 `yaml:"template"`
	Hostname             string                 `yaml:"hostname,omitempty" validate:"omitempty,plainhostname"`
	Subdomain            string                 `yaml:"subdomain,omitempty" validate:"omitempty,plainhostname"`
	Image                string                 `yaml:"image" validate:"required"`
	ImagePullPolicy      string                 `yaml:"imagePullPolicy,omitempty" validate:"omitempty,oneof=Always Never IfNotPresent"`
	K8shelld             K8shelld               `yaml:"k8shelld" validate:"required"`
	Env                  map[string]string      `yaml:"env,omitempty" default:"{}"`
	Network              Network                `yaml:"network,omitempty" default:"{networkPolicyClass:workspace}"`
	Resources            Resources              `yaml:"resources,omitempty" default:"{limits:{cpu:500m,memory:512Mi}}"`
	Podman               Podman                 `yaml:"podman,omitempty" default:"{enabled:false}"`
	Storages             map[string]Storage     `yaml:"storages,omitempty" default:"{}"`
	InitScripts          []InitScript           `yaml:"initScripts,omitempty" default:"[]" validate:"dive"`
	ShowInitScriptStatus bool                   `yaml:"showInitScriptStatus,omitempty" default:"false"`
	SecurityContext      map[string]interface{} `yaml:"securityContext,omitempty" default:"{}"`
	ExtFiles             map[string]string      `yaml:"extFiles,omitempty" default:"{}"`
	EnableApps           bool                   `yaml:"enableApps,omitempty" default:"false"`
	Apps                 map[string]AppSpec     `yaml:"apps,omitempty" default:"{}"`
}

Blueprint represents a single blueprint configuration

func (*Blueprint) Validate

func (b *Blueprint) Validate() v.Validator

Validate validates the blueprint and returns user-friendly errors

type BlueprintMetadata

type BlueprintMetadata struct {
	Name        string `yaml:"name"`
	RepoName    string `yaml:"repoName"`
	RepoRef     string `yaml:"repoRef"`
	RepoOwner   string `yaml:"repoOwner"`
	RepoAddress string `yaml:"repoAddress"`
}

BlueprintMetadata holds metadata information for a blueprint.

type BlueprintSummary

type BlueprintSummary struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	IsTemplate  bool   `json:"isTemplate,omitempty"`
}

type CompleteUserWebFlow

type CompleteUserWebFlow struct {
	Code  string `json:"code"`
	State string `json:"state"`
}

CompleteUserWebFlow represents the data needed to complete a web onboarding flow

type Conn

type Conn struct {
	AllowAnyNS bool `yaml:"allowAnyNS,omitempty"`
	AllowAnySA bool `yaml:"allowAnySA,omitempty"`
}

type CustomBlueprint

type CustomBlueprint struct {
	Metadata             BlueprintMetadata
	Name                 string             `yaml:"name,omitempty"`
	Template             string             `yaml:"template" validate:"required"`
	Splash               string             `yaml:"splash,omitempty"`
	Image                string             `yaml:"image,omitempty"`
	Env                  map[string]string  `yaml:"env,omitempty"`
	Network              Network            `yaml:"network,omitempty"`
	Resources            Resources          `yaml:"resources,omitempty"`
	Storages             map[string]Storage `yaml:"storages,omitempty"`
	InitScripts          []InitScript       `yaml:"initScripts,omitempty"`
	ShowInitScriptStatus bool               `yaml:"showInitScriptStatus,omitempty"`
	EnableApps           bool               `yaml:"enableApps,omitempty"`
	Apps                 map[string]AppSpec `yaml:"apps,omitempty"`
}

CustomBlueprint represents a custom blueprint configuration

func ValidateK8shellFile

func ValidateK8shellFile(k8shellFile K8shellFile) (*CustomBlueprint, []string)

type FailedConnectionEvent

type FailedConnectionEvent struct {
	ClientIP    string   `json:"clientIP"`
	ClientPort  int      `json:"clientPort"`
	Username    string   `json:"username"`
	Timestamp   string   `json:"timestamp"`
	FailureInfo []string `json:"failureInfo"`
	ProxyID     string   `json:"proxyID"`
}

FailedConnectionEvent represents a failed SSH connection attempt

type InitScript

type InitScript struct {
	Name   string `yaml:"name" validate:"required"`
	Script string `yaml:"script" validate:"required"`
}

InitScript represents a named initialization script

type K8shellFile

type K8shellFile struct {
	Blueprint CustomBlueprint `yaml:"blueprint" validate:"required"`
}

K8shellFile represents the overall structure of a k8shell YAML file

type K8shelld

type K8shelld struct {
	Image           string   `yaml:"image" validate:"required"`
	ImagePullPolicy string   `yaml:"imagePullPolicy,omitempty" validate:"omitempty,oneof=Always Never IfNotPresent"`
	IgnoreOrphans   []string `yaml:"ignoreOrphans,omitempty" default:"[]"`
	Connection      Conn     `yaml:"connection,omitempty"`
}

K8shelld represents k8shelld configuration

type Network

type Network struct {
	// NetworkPolicyClass selects a predefined network policy class (workspace, system, isolated, user, organization).
	NetworkPolicyClass string `yaml:"networkPolicyClass,omitempty" validate:"omitempty,oneof=workspace system isolated user organization"`
	// AllowEgressToCIDRs is a convenience shorthand for permitting egress to specific CIDR ranges.
	AllowEgressToCIDRs []string `yaml:"allowEgressToCIDRs,omitempty" validate:"dive,cidr"`
	// AllowEgressToPods is a convenience shorthand for permitting egress to pods matching label selectors.
	AllowEgressToPods []map[string]string `yaml:"allowEgressToPods,omitempty"`
}

Network defines network policy and egress rules for a workspace.

type OnboardCapability

type OnboardCapability struct {
	Provider   string `json:"provider"`
	Username   string `json:"username"`
	CanOnboard bool   `json:"canOnboard"`
}

OnboardCapability represents the capability of a user to onboard

type OnboardUserDeviceFlow

type OnboardUserDeviceFlow struct {
	Provider        string `json:"provider"`
	Username        string `json:"username"`
	UserCode        string `json:"userCode"`
	VerificationUrl string `json:"verificationUrl"`
	ExpiresIn       int    `json:"expiresIn"`
}

OnboardUserDeviceFlow represents a user being onboarded via OAuth device flow

type OnboardUserWebFlow

type OnboardUserWebFlow struct {
	Provider         string `json:"provider"`
	AuthorizationURL string `json:"authorizationUrl"`
	State            string `json:"state"`
	ExpiresIn        int    `json:"expiresIn"`
}

OnboardUserWebFlow represents a user being onboarded via OAuth web flow

type Organization

type Organization struct {
	Name        string `yaml:"name" json:"name"`
	Description string `yaml:"description" json:"description"`
}

Organization represents an organization in the system

type Podman

type Podman struct {
	Enabled                 bool                   `yaml:"enabled" default:"false"`
	Image                   string                 `yaml:"image" validate:"required_if=Enabled true"`
	Resources               Resources              `yaml:"resources" default:"{cpu:500m,memory:512Mi}"`
	CreateDockerSockSymlink bool                   `yaml:"createDockerSockSymlink" default:"false"`
	ParentStorages          bool                   `yaml:"parentStorages" default:"true"`
	ExtFiles                map[string]string      `yaml:"extFiles,omitempty" default:"{}"`
	Storages                map[string]Storage     `yaml:"storages,omitempty" default:"{}"`
	SecurityContext         map[string]interface{} `yaml:"securityContext,omitempty" default:"{}"`
}

Podman represents Podman configuration

type ProviderInfo

type ProviderInfo struct {
	Status          string     `yaml:"status" json:"status"`
	CreatedAt       time.Time  `yaml:"createdAt" json:"createdAt"`
	UpdatedAt       time.Time  `yaml:"updatedAt" json:"updatedAt"`
	Username        string     `yaml:"username" json:"username"`
	Provider        string     `yaml:"provider" json:"provider"`
	UserCode        string     `yaml:"userCode" json:"userCode"`
	DeviceCode      string     `yaml:"deviceCode" json:"deviceCode"`
	ExpiresAt       *time.Time `yaml:"expiresAt" json:"expiresAt"`
	VerificationURI string     `yaml:"verificationURI" json:"verificationURI"`
	AccessToken     string     `yaml:"accessToken" json:"accessToken"`
	RefreshToken    string     `yaml:"refreshToken" json:"refreshToken"`
}

ProviderInfo holds information about a identity provider

type ProvisionJob

type ProvisionJob struct {
	ID            string                 `json:"id"`
	WorkspaceName string                 `json:"workspaceName,omitempty"`
	Username      string                 `json:"username,omitempty"`
	Status        ProvisionJobStatus     `json:"status"`
	CreatedAt     time.Time              `json:"createdAt"`
	UpdatedAt     time.Time              `json:"updatedAt"`
	FinishedAt    time.Time              `json:"finishedAt,omitempty"`
	Events        []WorkspaceStreamEvent `json:"events,omitempty"`
}

ProvisionJob represents the state of a workspace provisioning job, The provisioning job is stored in a JetStream KV store, and updated as new events are received from the provisioner service.

type ProvisionJobStatus

type ProvisionJobStatus string
const (
	ProvisionJobRunning   ProvisionJobStatus = "running"
	ProvisionJobCompleted ProvisionJobStatus = "completed"
)

type Resources

type Resources struct {
	CPU    string `yaml:"cpu" validate:"required"`
	Memory string `yaml:"memory" validate:"required"`
}

Resources represents resource limits

type Role

type Role string

User roles

const (
	RoleAdmin          Role = "admin"
	RoleOrgAdmin       Role = "org-admin"
	RoleWorkspaceAdmin Role = "workspace-admin"
	RoleWorkspaceUser  Role = "workspace-user"
)

type SSHSession

type SSHSession struct {
	SessionID   string     `yaml:"sessionID" json:"sessionID"`
	Username    string     `yaml:"username" json:"username"`
	K8shelldVer string     `yaml:"k8shelldVer" json:"k8shelldVer"`
	Client      string     `yaml:"client" json:"client"`
	ClientIP    string     `yaml:"clientIP" json:"clientIP"`
	StartTime   *time.Time `yaml:"startTime" json:"startTime"`
	EndTime     *time.Time `yaml:"endTime" json:"endTime"`
	Workspace   string     `yaml:"workspace" json:"workspace"`
	BytesIn     int64      `yaml:"bytesIn" json:"bytesIn"`
	BytesOut    int64      `yaml:"bytesOut" json:"bytesOut"`
	Channels    []string   `yaml:"channels" json:"channels"`
	Blueprint   string     `yaml:"blueprint" json:"blueprint"`
	UpdatedAt   *time.Time `yaml:"updatedAt" json:"updatedAt"`
	PtyName     string     `yaml:"ptyName" json:"ptyName"`
}

SSHSession represents an SSH session for a user

type Storage

type Storage struct {
	Enabled  bool   `yaml:"enabled" default:"false"`
	Id       string `yaml:"id,omitempty" validate:"omitempty,alphanum"`
	Type     string `yaml:"type,omitempty" validate:"omitempty,oneof=local shared emptyDir memory" default:"local"`
	Path     string `yaml:"path" validate:"required_if=Enabled true,startswith=/"`
	Readonly bool   `yaml:"readonly" default:"false"`
	// SizeLimit applies to emptyDir and memory types (maps to emptyDir.sizeLimit)
	SizeLimit            string                 `yaml:"sizeLimit,omitempty"`
	ExistingClaim        string                 `yaml:"existingClaim,omitempty" validate:"required_if=Type shared Enabled true"`
	FsOwnerUid           *int                   `yaml:"fsOwnerUid,omitempty"`
	FsOwnerGid           *int                   `yaml:"fsOwnerGid,omitempty"`
	ClaimSpec            map[string]interface{} `yaml:"claimSpec,omitempty" default:"{}"`
	ClaimSpecAnnotations map[string]string      `yaml:"claimSpecAnnotations,omitempty" default:"{}"`
}

Storage represents storage configuration

type User

type User struct {
	Username     string    `yaml:"username" json:"username"`
	Organization string    `yaml:"organization" json:"organization"`
	IsValid      bool      `yaml:"isValid" json:"isValid"`
	ExpiresAt    time.Time `yaml:"expiresAt" json:"expiresAt"`
	UID          uint32    `yaml:"uid" json:"uid"`
	GID          uint32    `yaml:"gid" json:"gid"`
	Fullname     string    `yaml:"fullname" json:"fullname"`
	Email        string    `yaml:"email" json:"email"`
	Password     string    `yaml:"password,omitempty" json:"password,omitempty"`
	Auths        []string  `yaml:"auths" json:"auths"`
	AuthKeys     []string  `yaml:"authKeys" json:"authKeys"`
	Locked       bool      `yaml:"locked" json:"locked"`
	Roles        []Role    `yaml:"roles" json:"roles"`
	Blueprints   []string  `yaml:"blueprints" json:"blueprints"`
	Source       string    `yaml:"source" json:"source"`
	Shell        string    `yaml:"shell" json:"shell"`
	Sudo         bool      `yaml:"sudo" json:"sudo"`
}

User represents a user in the system

func (*User) HasBlueprint

func (u *User) HasBlueprint(blueprintName string) bool

type UserBlueprintsRequest added in v0.29.12

type UserBlueprintsRequest struct {
	Blueprints []string `json:"blueprints"`
}

UserBlueprintsRequest is the HTTP request body for adding or removing blueprints on a user. Note: proto counterpart is identityv1.UserBlueprintsRequest.

type UserCredential

type UserCredential struct {
	ID               uint32     `json:"id"`
	Username         string     `json:"username"`
	ServiceName      string     `json:"serviceName"`
	ServiceScope     string     `json:"serviceScope"`
	CredentialSource string     `json:"credentialSource"`
	Subject          string     `json:"subject"`
	Secret           string     `json:"secret,omitempty"`
	IsActive         bool       `json:"isActive"`
	CreatedAt        time.Time  `json:"createdAt"`
	UpdatedAt        time.Time  `json:"updatedAt"`
	ExpiresAt        *time.Time `json:"expiresAt,omitempty"`
}

UserCredential represents external service credentials for a user

type UserKeysRequest added in v0.29.12

type UserKeysRequest struct {
	Keys []string `json:"keys"`
}

UserKeysRequest is the HTTP request body for adding or removing SSH public keys on a user. Note: proto counterpart is identityv1.UserAuthKeysRequest.

type UserRolesRequest added in v0.29.12

type UserRolesRequest struct {
	Roles []Role `json:"roles"`
}

UserRolesRequest is the HTTP request body for adding or removing roles on a user. Note: proto counterpart is identityv1.UserRolesRequest.

type UserToken

type UserToken struct {
	Provider string `json:"provider"`
	Address  string `json:"address"`
	Username string `json:"username"`
	Token    string `json:"token"`
}

UserToken represents a token for a user

type UserUpdateRequest added in v0.29.12

type UserUpdateRequest struct {
	Fullname   *string  `json:"fullname,omitempty"`
	Shell      *string  `json:"shell,omitempty"`
	Org        *string  `json:"org,omitempty"`
	Roles      []Role   `json:"roles,omitempty"`
	Sudo       *bool    `json:"sudo,omitempty"`
	Blueprints []string `json:"blueprints,omitempty"`
	Locked     *bool    `json:"locked,omitempty"`
	Keys       []string `json:"keys,omitempty"`
}

UserUpdateRequest is the HTTP request body for PATCH /users/{username}. Only non-nil pointer fields and non-empty slices are applied (PATCH semantics). Note: proto counterpart is identityv1.UpdateUserRequest (different wire format, no json tags).

type WorkspaceDetails

type WorkspaceDetails struct {
	WorkspaceStatus
	AppVersion   string `json:"appVersion" example:"1.0.0"`
	Name         string `json:"name"`
	Username     string `json:"username"`
	RepoOwner    string `json:"repoOwner,omitempty"`
	RepoName     string `json:"repoName,omitempty"`
	RepoRef      string `json:"repoRef,omitempty"`
	Blueprint    string `json:"blueprint"`
	Organization string `json:"organization"`
	CPU          string `json:"cpu" example:"500m"`
	Memory       string `json:"memory" example:"256Mi"`
	ServerName   string `json:"serverName"`
	PodIP        string `json:"podIP"`
	Port         int    `json:"port"`
	TLSEnabled   bool   `json:"tlsEnabled"`
	Namespace    string `json:"namespace"`
	Hostname     string `json:"hostname,omitempty"`
	JobId        string `json:"jobId,omitempty"`
}

WorkspaceDetails represents the details of a workspace It contains information about the workspace pod status and in addition

type WorkspaceResources

type WorkspaceResources struct {
	CPU    string `json:"cpu" example:"500m"`
	Memory string `json:"memory" example:"256Mi"`
}

WorkspaceCreateRequest represents workspace resources (CPU and memory) It is used when updating the workspace resources via the API

type WorkspaceStatus

type WorkspaceStatus struct {
	Created         time.Time              `json:"created" example:"2025-08-05T10:30:00Z"`
	Status          WorkspaceStatusMessage `json:"status" example:"Running"`
	Message         string                 `json:"message" example:"Workspace is running"`
	Restarts        int32                  `json:"restarts" example:"0"`
	LastFailMessage string                 `json:"lastFailMessage,omitempty" example:""`
}

WorkspaceStatus represents the status of a workspace pod

type WorkspaceStatusMessage

type WorkspaceStatusMessage string

WorkspaceStatusMessage is the user-friendly status reported for a workspace pod.

const (
	WorkspaceStatusProvisioning WorkspaceStatusMessage = "Starting"
	WorkspaceStatusWarning      WorkspaceStatusMessage = "Warning"
	WorkspaceStatusPulling      WorkspaceStatusMessage = "Pulling"
	WorkspaceStatusRunning      WorkspaceStatusMessage = "Running"
	WorkspaceStatusFailing      WorkspaceStatusMessage = "Failing"
	WorkspaceStatusTerminating  WorkspaceStatusMessage = "Terminating"
	WorkspaceStatusStopped      WorkspaceStatusMessage = "Stopped"
	WorkspaceStatusError        WorkspaceStatusMessage = "Error"
	WorkspaceStatusUnknown      WorkspaceStatusMessage = "Unknown"
)

type WorkspaceStreamEvent

type WorkspaceStreamEvent struct {
	Id         int64                    `json:"id" example:"123456789"`
	Type       WorkspaceStreamEventType `json:"type" example:"event"`
	Timestamp  string                   `json:"timestamp,omitempty" example:"2025-08-05T10:30:00Z"`
	ObjectName string                   `json:"objectName,omitempty" example:"dev-user123"`
	Message    string                   `json:"message,omitempty" example:"Pod is starting"`
	Status     WorkspaceStatusMessage   `json:"status,omitempty" example:"Running"`
}

StreamEvent represents a streaming event response

func (WorkspaceStreamEvent) String

func (e WorkspaceStreamEvent) String() string

type WorkspaceStreamEventType

type WorkspaceStreamEventType string
const (
	WorkspaceStreamEventTypeEvent    WorkspaceStreamEventType = "event"
	WorkspaceStreamEventTypeStatus   WorkspaceStreamEventType = "status"
	WorkspaceStreamEventTypeProgress WorkspaceStreamEventType = "progress"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL