model

package
v0.0.0-...-609bd80 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// ActivityBeingCreated is used when a model is being created.
	ActivityBeingCreated = "beingCreated"

	// ActivityBeingDeleted is used when a model is being deleted.
	ActivityBeingDeleted = "beingDeleted"

	// ActivityUpdating is used when a model is being updated.
	ActivityUpdating = "updating"

	// ActivityRestarting is used when a model is being restarted.
	ActivityRestarting = "restarting"

	// ActivityBuilding is used when a model is being built.
	ActivityBuilding = "building"

	// ActivityRepairing is used when a model is being repaired.
	ActivityRepairing = "repairing"
)
View Source
const (
	// CustomDomainStatusPending is the status of a custom domain that is pending verification.
	CustomDomainStatusPending = "pending"
	// CustomDomainStatusVerificationFailed is the status of a custom domain that failed verification.
	// This is either caused by the DNS record not being set or the DNS record not being propagated yet.
	CustomDomainStatusVerificationFailed = "verificationFailed"
	// CustomDomainStatusActive is the status of a custom domain that is active,
	// i.e., the DNS record is set and propagated.
	CustomDomainStatusActive = "active"
)
View Source
const (
	// DeploymentTypeCustom is a deployment that builds its own image, e.g., with a Dockerfile.
	DeploymentTypeCustom = "custom"
	// DeploymentTypePrebuilt is a deployment that uses a prebuilt image, such as nginx:latest.
	DeploymentTypePrebuilt = "prebuilt"

	// LogSourcePod is a log source for a pod in Kubernetes.
	LogSourcePod = "pod"
	// LogSourceDeployment is a log source for a deployment in go-deploy.
	LogSourceDeployment = "deployment"
	// LogSourceBuild is a log source for a build in GitLab CI.
	LogSourceBuild = "build"

	// VisibilityPublic is a public app.
	VisibilityPublic = "public"
	// VisibilityPrivate is a private app.
	VisibilityPrivate = "private"
	// VisibilityAuth is an app that requires authentication.
	VisibilityAuth = "auth"
)
View Source
const (
	// JobCreateVM is used when creating a VM.
	JobCreateVM = "createVm"
	// JobDeleteVM is used when deleting a VM.
	JobDeleteVM = "deleteVm"
	// JobUpdateVM is used when updating a VM.
	JobUpdateVM = "updateVm"
	// JobUpdateVmOwner is used when updating a VM's owner.
	JobUpdateVmOwner = "updateVmOwner"
	// JobRepairVM is used when repairing a VM.
	JobRepairVM = "repairVm"
	// JobCreateGpuLease is used when creating a GPU lease for a VM.
	JobCreateGpuLease = "createGpuLease"
	// JobUpdateGpuLease is used when updating a GPU lease for a VM.
	JobUpdateGpuLease = "updateGpuLease"
	// JobDeleteGpuLease is used when deleting a GPU lease for a VM.
	JobDeleteGpuLease = "deleteGpuLease"
	// JobCreateSystemVmSnapshot is used when creating a snapshot requested by the system.
	// This is separate from JobCreateVmUserSnapshot because the system can create any number of snapshots.
	JobCreateSystemVmSnapshot = "createSystemSnapshot"
	// JobCreateVmUserSnapshot is used when creating a snapshot requested by a user.
	// This is separate from JobCreateSystemVmSnapshot because the system can create any number of snapshots.
	JobCreateVmUserSnapshot = "createUserSnapshot"
	// JobDeleteVmSnapshot is used when deleting a snapshot.
	JobDeleteVmSnapshot = "deleteSnapshot"
	// JobDoVmAction is used when doing an action on a VM.
	JobDoVmAction = "doVmAction"

	// JobCreateDeployment is used when creating a deployment.
	JobCreateDeployment = "createDeployment"
	// JobDeleteDeployment is used when deleting a deployment.
	JobDeleteDeployment = "deleteDeployment"
	// JobUpdateDeployment is used when updating a deployment.
	JobUpdateDeployment = "updateDeployment"
	// JobUpdateDeploymentOwner is used when updating a deployment's owner.
	JobUpdateDeploymentOwner = "updateDeploymentOwner"
	// JobRepairDeployment is used when repairing a deployment.
	JobRepairDeployment = "repairDeployment"

	// JobCreateSM is used when creating a storage manager.
	JobCreateSM = "createSm"
	// JobDeleteSM is used when deleting a storage manager.
	JobDeleteSM = "deleteSm"
	// JobRepairSM is used when repairing a storage manager.
	JobRepairSM = "repairSm"

	// JobCreateGpuClaim is used when creating a gpu claim.
	JobCreateGpuClaim = "createGpuClaim"
	// JobCreateGpuClaim is used when deleting a gpu claim.
	JobDeleteGpuClaim = "deleteGpuClaim"
	// JobUpdateGpuClaim is used when updating a gpu claim
	JobUpdateGpuClaim = "updateGpuClaim"
)
View Source
const (
	// JobStatusPending is used when a job is pending and waiting to be run.
	JobStatusPending = "pending"
	// JobStatusRunning is used when a job is running.
	JobStatusRunning = "running"
	// JobStatusCompleted is used when a job is completed.
	JobStatusCompleted = "completed"
	// JobStatusFailed is used when a job has failed.
	JobStatusFailed = "failed"
	// JobStatusTerminated is used when a job has been terminated.
	JobStatusTerminated = "terminated"
)
View Source
const (
	// NotificationTeamInvite is used for team invite notifications.
	NotificationTeamInvite = "teamInvite"
	// NotificationResourceTransfer is used for resource migration notifications.
	NotificationResourceTransfer = "resourceTransfer"
)
View Source
const (
	ResourceTypeDeployment = "deployment"
	ResourceTypeVM         = "vm"
	ResourceTypeSM         = "sm"
	ResourceTypeTeam       = "team"
)
View Source
const (
	ResourceMigrationTypeUpdateOwner = "updateOwner"

	ResourceMigrationStatusPending  = "pending"
	ResourceMigrationStatusAccepted = "accepted"
)
View Source
const (
	// TeamMemberRoleAdmin is the role used for admin members in a team.
	// This is currently not used, and every member is an admin.
	TeamMemberRoleAdmin = "admin"

	// TeamMemberStatusInvited is the status used for users that have been invited to a team.
	TeamMemberStatusInvited = "invited"
	// TeamMemberStatusJoined is the status used for users that have joined a team.
	TeamMemberStatusJoined = "joined"
)
View Source
const (
	TestAdminUserID   = "955f0f87-37fd-4792-90eb-9bf6989e698a"
	TestPowerUserID   = "955f0f87-37fd-4792-90eb-9bf6989e698b"
	TestDefaultUserID = "955f0f87-37fd-4792-90eb-9bf6989e698c"

	TestAdminUserApiKey   = "test-api-key-admin"
	TestPowerUserApiKey   = "test-api-key-power"
	TestDefaultUserApiKey = "test-api-key-default"
)
View Source
const (
	ActionStart            = "start"
	ActionStop             = "stop"
	ActionRestart          = "restart"
	ActionRestartIfRunning = "restartIfRunning"
)
View Source
const (
	NLogsCache = 100
)
View Source
const (
	// TypeHttpRequest is the event type of HTTP requests.
	TypeHttpRequest = "httpRequest"
)

Variables

View Source
var (
	ErrUnknownParameterImplType = errors.New("unknown underlying opaque GPU config type")
	ErrCouldNotInferDriver      = errors.New("could not infer driver")
)
View Source
var EmptyReplicaStatus = &ReplicaStatus{}
View Source
var FetchGravatarInterval = 10 * time.Minute

FetchGravatarInterval is the interval at which we fetch the gravatar image for a user. This is done to prevent fetching the image on every request.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Name      string    `bson:"name"`
	CreatedAt time.Time `bson:"createdAt"`
}

type AllocatedGpu

type AllocatedGpu struct {
	Pool        string `bson:"pool,omitempty"`
	Device      string `bson:"device,omitempty"`
	ShareID     string `bson:"shareID,omitempty"`
	AdminAccess bool   `bson:"adminAccess,omitempty"`
}

AllocatedGpu represents a concrete allocated GPU or GPU share.

type ApiKey

type ApiKey struct {
	Name      string    `bson:"name"`
	Key       string    `bson:"key"`
	CreatedAt time.Time `bson:"createdAt"`
	ExpiresAt time.Time `bson:"expiresAt"`
}

func (*ApiKey) ToDTO

func (apiKey *ApiKey) ToDTO() body.ApiKeyCreated

type ApiKeyCreateParams

type ApiKeyCreateParams struct {
	Name      string    `json:"name"`
	Key       string    `json:"key"`
	ExpiresAt time.Time `json:"expiresAt"`
}

func (ApiKeyCreateParams) FromDTO

func (apiKey ApiKeyCreateParams) FromDTO(dto *body.ApiKeyCreate, key string) *ApiKeyCreateParams

type App

type App struct {
	Name string `bson:"name"`

	CpuCores float64         `bson:"cpuCores,omitempty"`
	RAM      float64         `bson:"ram,omitempty"`
	Replicas int             `bson:"replicas"`
	GPUs     []DeploymentGPU `bson:"gpus,omitempty"`

	Image         string             `bson:"image"`
	InternalPort  int                `bson:"internalPort"`
	InternalPorts []int              `bson:"internalPorts"`
	Envs          []DeploymentEnv    `bson:"envs"`
	Volumes       []DeploymentVolume `bson:"volumes"`
	Visibility    string             `bson:"visibility"`

	// Deprecated: use Visibility instead.
	Private bool `bson:"private"`

	Args         []string `bson:"args"`
	InitCommands []string `bson:"initCommands"`

	CustomDomain *CustomDomain `bson:"customDomain"`

	// ReplicaStatus is a group of fields that describe the status of the replicas.
	// It is only set for apps that has status update.
	ReplicaStatus *ReplicaStatus `bson:"replicaStatus,omitempty"`

	PingPath   string `bson:"pingPath"`
	PingResult int    `bson:"pingResult"`
}

type AuthParams

type AuthParams struct {
	UserID    string `json:"userId"`
	Username  string `json:"username"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Email     string `json:"email"`
	IsAdmin   bool   `json:"isAdmin"`
	Roles     []Role `json:"roles"`
}

type CreateSnapshotParams

type CreateSnapshotParams struct {
	Name        string `bson:"name"`
	UserCreated bool   `bson:"userCreated"`
	Overwrite   bool   `bson:"overwrite"`
}

func (*CreateSnapshotParams) FromDTOv2

func (sc *CreateSnapshotParams) FromDTOv2(dto *body.VmSnapshotCreate)

FromDTOv2 converts a body.VmSnapshotCreate to a CreateSnapshotParams.

type CustomDomain

type CustomDomain struct {
	Domain string `bson:"domain"`
	Secret string `bson:"secret"`
	Status string `bson:"status"`
}

type Deployment

type Deployment struct {
	ID      string `bson:"id"`
	Name    string `bson:"name"`
	Type    string `bson:"type"`
	OwnerID string `bson:"ownerId"`
	Zone    string `bson:"zone"`

	CreatedAt   time.Time `bson:"createdAt"`
	UpdatedAt   time.Time `bson:"updatedAt"`
	RepairedAt  time.Time `bson:"repairedAt"`
	RestartedAt time.Time `bson:"restartedAt"`
	DeletedAt   time.Time `bson:"deletedAt"`
	AccessedAt  time.Time `bson:"accessedAt"`

	NeverStale bool `bson:"neverStale"`

	Activities map[string]Activity `bson:"activities"`

	Apps       map[string]App       `bson:"apps"`
	Subsystems DeploymentSubsystems `bson:"subsystems"`
	Logs       []Log                `bson:"logs"`

	Status string `bson:"status"`
	// Error is set if there is an error with the deployment.
	// The error is not cleared until the deployment is in a healthy state.
	Error *DeploymentError `bson:"error,omitempty"`
}

func (*Deployment) BeingCreated

func (deployment *Deployment) BeingCreated() bool

BeingCreated returns true if the deployment is being created.

func (*Deployment) BeingDeleted

func (deployment *Deployment) BeingDeleted() bool

BeingDeleted returns true if the deployment is being deleted.

func (*Deployment) DoingActivity

func (deployment *Deployment) DoingActivity(activity string) bool

DoingActivity returns true if the deployment is doing the given activity.

func (*Deployment) GetMainApp

func (deployment *Deployment) GetMainApp() *App

GetMainApp returns the main app of the deployment. If the app does not exist, it will panic.

func (*Deployment) GetURL

func (deployment *Deployment) GetURL(externalPort *int) *string

GetURL returns the URL of the deployment. If the K8s ingress does not exist, it will return nil, or if the ingress does not have a host, it will return nil.

func (*Deployment) Ready

func (deployment *Deployment) Ready() bool

Ready returns true if the deployment is not being created or deleted.

func (*Deployment) SetMainApp

func (deployment *Deployment) SetMainApp(app *App)

SetMainApp sets the main app of the deployment. If the app map is nil, it will be initialized before setting the app.

func (*Deployment) ToDTO

func (deployment *Deployment) ToDTO(smURL *string, externalPort *int, teams []string) body.DeploymentRead

ToDTO converts a Deployment to a body.DeploymentRead DTO.

type DeploymentCreateParams

type DeploymentCreateParams struct {
	Name string
	Type string

	CpuCores float64
	RAM      float64
	Replicas int
	GPUs     []DeploymentGPU

	Image         string
	InternalPort  int
	InternalPorts []int
	Envs          []DeploymentEnv
	Volumes       []DeploymentVolume
	InitCommands  []string
	Args          []string
	PingPath      string
	CustomDomain  *string
	Visibility    string

	NeverStale bool

	Zone string
}

func (*DeploymentCreateParams) FromDTO

func (p *DeploymentCreateParams) FromDTO(dto *body.DeploymentCreate, fallbackZone, fallbackImage string, fallbackPort int)

FromDTO converts body.DeploymentCreate DTO to DeploymentCreateParams.

type DeploymentEnv

type DeploymentEnv struct {
	Name  string `json:"name" bson:"name"`
	Value string `json:"value" bson:"value"`
}

type DeploymentError

type DeploymentError struct {
	Reason      string `bson:"reason"`
	Description string `bson:"description"`
}

type DeploymentEvent

type DeploymentEvent struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Reason      string `json:"reason"`
	Description string `json:"description"`
	ObjectKind  string `json:"objectKind"`
}

type DeploymentGPU

type DeploymentGPU struct {
	Name      string `bson:"name"`
	ClaimName string `bson:"claimName"`
}

type DeploymentHarbor

type DeploymentHarbor struct {
	Project     harborModels.ProjectPublic    `bson:"project"`
	Robot       harborModels.RobotPublic      `bson:"robot"`
	Repository  harborModels.RepositoryPublic `bson:"repository"`
	Webhook     harborModels.WebhookPublic    `bson:"webhook"`
	Placeholder bool                          `bson:"placeholder"`
}

type DeploymentK8s

type DeploymentK8s struct {
	Namespace k8sModels.NamespacePublic `bson:"namespace"`

	DeploymentMap    map[string]k8sModels.DeploymentPublic    `bson:"deploymentMap,omitempty"`
	ServiceMap       map[string]k8sModels.ServicePublic       `bson:"serviceMap,omitempty"`
	IngressMap       map[string]k8sModels.IngressPublic       `bson:"ingressMap,omitempty"`
	PvMap            map[string]k8sModels.PvPublic            `bson:"pvMap,omitempty"`
	PvcMap           map[string]k8sModels.PvcPublic           `bson:"pvcMap,omitempty"`
	SecretMap        map[string]k8sModels.SecretPublic        `bson:"secretMap,omitempty"`
	HpaMap           map[string]k8sModels.HpaPublic           `bson:"hpaMap,omitempty"`
	NetworkPolicyMap map[string]k8sModels.NetworkPolicyPublic `bson:"networkPolicyMap,omitempty"`
}

func (*DeploymentK8s) DeleteDeployment

func (k *DeploymentK8s) DeleteDeployment(name string)

DeleteDeployment deletes the deployment from the DeploymentMap with the given name. It uses GetDeploymentMap to get the map to avoid nil pointer dereferences.

func (*DeploymentK8s) DeleteHPA

func (k *DeploymentK8s) DeleteHPA(name string)

DeleteHPA deletes the HPA from the HpaMap with the given name. It uses GetHpaMap to get the map to avoid nil pointer dereferences.

func (*DeploymentK8s) DeleteIngress

func (k *DeploymentK8s) DeleteIngress(name string)

DeleteIngress deletes the ingress from the IngressMap with the given name. It uses GetIngressMap to get the map to avoid nil pointer dereferences.

func (*DeploymentK8s) DeletePV

func (k *DeploymentK8s) DeletePV(name string)

DeletePV deletes the PV from the PvMap with the given name. It uses GetPvMap to get the map to avoid nil pointer dereferences.

func (*DeploymentK8s) DeletePVC

func (k *DeploymentK8s) DeletePVC(name string)

DeletePVC deletes the PVC from the PvcMap with the given name. It uses GetPvcMap to get the map to avoid nil pointer dereferences.

func (*DeploymentK8s) DeleteSecret

func (k *DeploymentK8s) DeleteSecret(name string)

DeleteSecret deletes the secret from the SecretMap with the given name. It uses GetSecretMap to get the map to avoid nil pointer dereferences.

func (*DeploymentK8s) DeleteService

func (k *DeploymentK8s) DeleteService(name string)

DeleteService deletes the service from the ServiceMap with the given name. It uses GetServiceMap to get the map to avoid nil pointer dereferences.

func (*DeploymentK8s) GetDeployment

func (k *DeploymentK8s) GetDeployment(name string) *k8sModels.DeploymentPublic

GetDeployment returns the deployment with the given name. If a deployment with the given name does not exist, nil will be returned.

func (*DeploymentK8s) GetDeploymentMap

func (k *DeploymentK8s) GetDeploymentMap() map[string]k8sModels.DeploymentPublic

GetDeploymentMap returns the deployment map of the deployment. If the map is nil, it will be initialized before returning.

func (*DeploymentK8s) GetHPA

func (k *DeploymentK8s) GetHPA(name string) *k8sModels.HpaPublic

GetHPA returns the HPA with the given name. If a HPA with the given name does not exist, nil will be returned.

func (*DeploymentK8s) GetHpaMap

func (k *DeploymentK8s) GetHpaMap() map[string]k8sModels.HpaPublic

GetHpaMap returns the hpa map of the deployment. If the map is nil, it will be initialized before returning.

func (*DeploymentK8s) GetIngress

func (k *DeploymentK8s) GetIngress(name string) *k8sModels.IngressPublic

GetIngress returns the ingress with the given name. If an ingress with the given name does not exist, nil will be returned.

func (*DeploymentK8s) GetIngressMap

func (k *DeploymentK8s) GetIngressMap() map[string]k8sModels.IngressPublic

GetIngressMap returns the ingress map of the deployment. If the map is nil, it will be initialized before returning.

func (*DeploymentK8s) GetNamespace

func (k *DeploymentK8s) GetNamespace() *k8sModels.NamespacePublic

GetNamespace returns the namespace of the deployment.

func (*DeploymentK8s) GetNetworkPolicy

func (k *DeploymentK8s) GetNetworkPolicy(name string) *k8sModels.NetworkPolicyPublic

GetNetworkPolicy returns the network policy with the given name. If a network policy with the given name does not exist, nil will be returned.

func (*DeploymentK8s) GetNetworkPolicyMap

func (k *DeploymentK8s) GetNetworkPolicyMap() map[string]k8sModels.NetworkPolicyPublic

GetNetworkPolicyMap returns the network policy map of the deployment. If the map is nil, it will be initialized before returning.

func (*DeploymentK8s) GetPV

func (k *DeploymentK8s) GetPV(name string) *k8sModels.PvPublic

GetPV returns the PV with the given name. If a PV with the given name does not exist, nil will be returned.

func (*DeploymentK8s) GetPVC

func (k *DeploymentK8s) GetPVC(name string) *k8sModels.PvcPublic

GetPVC returns the PVC with the given name. If a PVC with the given name does not exist, nil will be returned.

func (*DeploymentK8s) GetPvMap

func (k *DeploymentK8s) GetPvMap() map[string]k8sModels.PvPublic

GetPvMap returns the pv map of the deployment. If the map is nil, it will be initialized before returning.

func (*DeploymentK8s) GetPvcMap

func (k *DeploymentK8s) GetPvcMap() map[string]k8sModels.PvcPublic

GetPvcMap returns the pvc map of the deployment. If the map is nil, it will be initialized before returning.

func (*DeploymentK8s) GetSecret

func (k *DeploymentK8s) GetSecret(name string) *k8sModels.SecretPublic

GetSecret returns the secret with the given name. If a secret with the given name does not exist, nil will be returned.

func (*DeploymentK8s) GetSecretMap

func (k *DeploymentK8s) GetSecretMap() map[string]k8sModels.SecretPublic

GetSecretMap returns the secret map of the deployment. If the map is nil, it will be initialized before returning.

func (*DeploymentK8s) GetService

func (k *DeploymentK8s) GetService(name string) *k8sModels.ServicePublic

GetService returns the service with the given name. If a service with the given name does not exist, nil will be returned.

func (*DeploymentK8s) GetServiceMap

func (k *DeploymentK8s) GetServiceMap() map[string]k8sModels.ServicePublic

GetServiceMap returns the service map of the deployment. If the map is nil, it will be initialized before returning.

type DeploymentStatus

type DeploymentStatus struct {
	Name                string `bson:"name"`
	Generation          int    `bson:"generation"`
	DesiredReplicas     int    `bson:"desiredReplicas"`
	ReadyReplicas       int    `bson:"readyReplicas"`
	AvailableReplicas   int    `bson:"availableReplicas"`
	UnavailableReplicas int    `bson:"unavailableReplicas"`
}

type DeploymentSubsystems

type DeploymentSubsystems struct {
	K8s    DeploymentK8s    `bson:"k8s"`
	Harbor DeploymentHarbor `bson:"harbor"`
}

type DeploymentUpdateOwnerParams

type DeploymentUpdateOwnerParams struct {
	NewOwnerID    string
	OldOwnerID    string
	MigrationCode *string
}

type DeploymentUpdateParams

type DeploymentUpdateParams struct {
	Name    *string
	OwnerID *string

	CpuCores *float64
	RAM      *float64
	GPUs     *[]DeploymentGPU

	Envs          *[]DeploymentEnv
	InternalPort  *int
	InternalPorts *[]int
	Volumes       *[]DeploymentVolume
	InitCommands  *[]string
	Args          *[]string
	CustomDomain  *string
	Image         *string
	PingPath      *string
	Replicas      *int
	Visibility    *string

	NeverStale *bool
}

func (*DeploymentUpdateParams) FromDTO

func (p *DeploymentUpdateParams) FromDTO(dto *body.DeploymentUpdate, deploymentType string)

FromDTO converts body.DeploymentUpdate DTO to DeploymentUpdateParams.

type DeploymentUsage

type DeploymentUsage struct {
	CpuCores float64
	RAM      float64
	Gpus     int
}

type DeploymentVolume

type DeploymentVolume struct {
	Name       string `bson:"name"`
	Init       bool   `bson:"init"`
	AppPath    string `bson:"appPath"`
	ServerPath string `bson:"serverPath"`
}

type Discover

type Discover struct {
	Version string
	Roles   []Role
}

func (*Discover) ToDTO

func (d *Discover) ToDTO() body2.DiscoverRead

type Docker

type Docker struct {
	RunsOn string  `yaml:"runs-on"`
	Steps  []Steps `yaml:"steps"`
}

type EffectiveRole

type EffectiveRole struct {
	Name        string `bson:"name"`
	Description string `bson:"description"`
}

type Event

type Event struct {
	ID        string    `bson:"id"`
	Type      string    `bson:"type"`
	CreatedAt time.Time `bson:"createdAt"`

	// Source is the source of an event, meaning from where the event originated.
	Source *Source `bson:"source,omitempty"`

	// Metadata contains any data related to the event.
	Metadata map[string]interface{} `bson:"metadata,omitempty"`
}

type EventCreateParams

type EventCreateParams struct {
	Type     string                 `bson:"type"`
	Source   *Source                `bson:"source,omitempty"`
	Metadata map[string]interface{} `bson:"metadata"`
}

type GithubActionConfig

type GithubActionConfig struct {
	Name string `yaml:"name"`
	On   On     `yaml:"on"`
	Jobs Jobs   `yaml:"jobs"`
}

type GpuClaim

type GpuClaim struct {
	ID   string `bson:"id"`
	Name string `bson:"name"`
	Zone string `bson:"zone"`

	// Requested contains all requested GPU configurations by key request.Name
	// this key is the key that users will request for
	Requested map[string]RequestedGpu `bson:"requested"`

	// Allocated contains the GPUs that have been successfully bound/allocated
	Allocated map[string][]AllocatedGpu `bson:"allocated,omitempty"`

	// Consumers are the workloads currently using this claim
	Consumers []GpuClaimConsumer `bson:"consumers,omitempty"`

	// Status reflects the reconciliation and/or lifecycle state
	Status *GpuClaimStatus `bson:"status,omitempty"`

	// LastError holds the last reconciliation or provisioning error
	LastError error `bson:"lastError,omitempty"`

	// The roles that are allowed to use this GpuClaim
	// Empty means all roles
	AllowedRoles []string `bson:"allowedRoles,omitempty"`

	Activities map[string]Activity `bson:"activities"`

	Subsystems GpuClaimSubsystems `bson:"subsystems"`

	CreatedAt time.Time  `bson:"createdAt"`
	UpdatedAt *time.Time `bson:"updatedAt,omitempty"`
}

GpuClaim represents a DRA-style claim for one or more GPUs that can be requested and consumed by deployments or workloads.

func (*GpuClaim) DoingActivity

func (gc *GpuClaim) DoingActivity(activity string) bool

DoingActivity returns true if the gpuClaim is doing the given activity.

func (*GpuClaim) HasAccess

func (gc *GpuClaim) HasAccess(roles ...string) bool

Check if a user is allowed to use a gpuClaim

func (GpuClaim) ToBriefDTO

func (g GpuClaim) ToBriefDTO() body.GpuClaimRead

func (GpuClaim) ToDTO

func (g GpuClaim) ToDTO() body.GpuClaimRead

type GpuClaimConsumer

type GpuClaimConsumer struct {
	APIGroup string `bson:"apiGroup,omitempty"`
	Resource string `bson:"resource,omitempty"`
	Name     string `bson:"name,omitempty"`
	UID      string `bson:"uid,omitempty"`
}

GpuClaimConsumer describes a workload (Pod/Deployment/etc.) consuming this GPU claim.

type GpuClaimCreateParams

type GpuClaimCreateParams struct {
	Name string `json:"name" bson:"name"`
	Zone string `json:"zone" bson:"zone"`

	Requested []RequestedGpuCreate `json:"requested" bson:"requested"`

	AllowedRoles []string `bson:"allowedRoles,omitempty"`
}

type GpuClaimK8s

type GpuClaimK8s struct {
	Namespace k8sModels.NamespacePublic `bson:"namespace"`

	ResourceClaimMap map[string]k8sModels.ResourceClaimPublic `bson:"resourceClaimMap,omitempty"`
}

func (*GpuClaimK8s) GetNamespace

func (k *GpuClaimK8s) GetNamespace() *k8sModels.NamespacePublic

GetNamespace returns the namespace of the resourceClaim.

type GpuClaimStatus

type GpuClaimStatus struct {
	Phase      GpuClaimStatusPhase `bson:"phase,omitempty"` // e.g. pending, bound, released, failed
	Message    string              `bson:"message,omitempty"`
	UpdatedAt  *time.Time          `bson:"updatedAt,omitempty"`
	LastSynced *time.Time          `bson:"lastSynced,omitempty"`
}

GpuClaimStatus represents runtime state and metadata about allocation progress.

type GpuClaimStatusPhase

type GpuClaimStatusPhase string
const (
	GpuClaimStatusPhase_Unknown GpuClaimStatusPhase = ""
	GpuClaimStatusPhase_Pending GpuClaimStatusPhase = "pending"
	GpuClaimStatusPhase_Bound   GpuClaimStatusPhase = "bound"
	GpuClaimStatusPhase_Failed  GpuClaimStatusPhase = "failed"
)

type GpuClaimSubsystems

type GpuClaimSubsystems struct {
	K8s GpuClaimK8s `bson:"k8s"`
}

type GpuClaimUpdateParams

type GpuClaimUpdateParams struct {
	Name *string `json:"name" bson:"name"`
	Zone *string `json:"zone" bson:"zone"`

	Requested *[]RequestedGpuCreate `json:"requested" bson:"requested"`

	AllowedRoles *[]string `bson:"allowedRoles,omitempty"`
}

type GpuDeviceConfiguration

type GpuDeviceConfiguration struct {
	Driver     string           `bson:"driver"`
	Parameters dra.OpaqueParams `bson:"parameters,omitempty"`
}

GpuDeviceConfiguration holds the DRA opaque driver parameters and metadata.

func (GpuDeviceConfiguration) InferDriver

func (g GpuDeviceConfiguration) InferDriver() (string, error)

InferDriver attempts to infer the GPU driver based on the OpaqueParams implementation.

func (GpuDeviceConfiguration) MarshalBSON

func (cfg GpuDeviceConfiguration) MarshalBSON() ([]byte, error)

func (*GpuDeviceConfiguration) UnmarshalBSON

func (cfg *GpuDeviceConfiguration) UnmarshalBSON(data []byte) error

type GpuGroup

type GpuGroup struct {
	// ID is just a hash of the name and zone to avoid any special characters in the name
	// To generate it use:
	//
	// utils.HashStringAlphanumericLower(fmt.Sprintf("%s-%s", Name, Zone)
	ID string `bson:"id"`
	// Name is the unique name for a group of GPUs.
	// This is used when attaching GPUs to a VM to create a host-agnostic identifier
	//
	// The name should be RFC1035 compliant, and is normally vendor/model, such as "nvidia/tesla-t4"
	Name        string `bson:"name"`
	DisplayName string `bson:"displayName"`
	Zone        string `bson:"zone"`
	Total       int    `bson:"total"`

	Vendor   string `bson:"vendor"`
	VendorID string `bson:"vendorId"`
	DeviceID string `bson:"deviceId"`
}

GpuGroup represents a group of GPUs for VM v2

func (*GpuGroup) ToDTO

func (gpuGroup *GpuGroup) ToDTO(leases int) body.GpuGroupRead

ToDTO converts a model.GpuGroup to a body.GpuGroupRead DTO.

type GpuLease

type GpuLease struct {
	ID         string `bson:"id"`
	GpuGroupID string `bson:"gpuGroupId"`
	UserID     string `bson:"userId"`

	// VmID is set to attach the lease to a VM.
	// If the lease is not attached to a VM, this field is nil.
	VmID *string `bson:"vmId"`

	LeaseDuration float64    `bson:"leaseDuration"`
	ActivatedAt   *time.Time `bson:"activatedAt,omitempty"`
	AssignedAt    *time.Time `bson:"assignedAt,omitempty"`
	ExpiredAt     *time.Time `bson:"expiredAt,omitempty"`
	CreatedAt     time.Time  `bson:"createdAt"`
}

func (*GpuLease) IsActive

func (g *GpuLease) IsActive() bool

IsActive returns true if the lease is active. An active lease is subject to be expired.

func (*GpuLease) IsExpired

func (g *GpuLease) IsExpired() bool

IsExpired returns true if the lease is expired.

func (*GpuLease) ToDTO

func (g *GpuLease) ToDTO(queuePosition int) body.GpuLeaseRead

ToDTO converts a GpuLease to a body.GpuLeaseRead DTO.

type GpuLeaseCreateParams

type GpuLeaseCreateParams struct {
	GpuGroupName string
	LeaseForever bool
}

func (GpuLeaseCreateParams) FromDTO

FromDTO converts body.GpuLeaseCreate DTO to GpuLeaseCreateParams.

type GpuLeaseUpdateParams

type GpuLeaseUpdateParams struct {
	ActivatedAt *time.Time
	VmID        *string
}

func (GpuLeaseUpdateParams) FromDTO

FromDTO converts body.GpuLeaseUpdate DTO to GpuLeaseUpdateParams.

type Gravatar

type Gravatar struct {
	// URL is the URL to the gravatar image.
	// If the URL is nil, the gravatar image has not been fetched yet, or the
	// user does not have a gravatar image.
	URL       *string   `bson:"url"`
	FetchedAt time.Time `bson:"fetchedAt"`
}

func CreateEmptyGravatar

func CreateEmptyGravatar() Gravatar

type Host

type Host struct {
	Name        string `json:"name" bson:"name"`
	DisplayName string `json:"displayName" bson:"displayName"`
	Zone        string `json:"zone" bson:"zone"`

	IP   string `json:"ip" bson:"ip"`
	Port int    `json:"port" bson:"port"`

	Enabled bool `json:"enabled" bson:"enabled"`
	// Schedulable is used to determine if a host is available for scheduling.
	// If a host is not schedulable, it will not be used for scheduling and if it has any GPUs, they won't be synchronized.
	// It is merely a synchronized state with the Kubernetes cluster to respect the host's state, such as when cordoning a node.
	Schedulable bool `json:"schedulable" bson:"schedulable"`

	DeactivatedUntil *time.Time `json:"deactivatedUntil,omitempty" bson:"deactivatedUntil,omitempty"`
	LastSeenAt       time.Time  `json:"lastSeenAt" bson:"lastSeenAt"`
	RegisteredAt     time.Time  `json:"registeredAt" bson:"registeredAt"`
}

func NewHostByParams

func NewHostByParams(params *body.HostRegisterParams) *Host

func (*Host) ApiURL

func (host *Host) ApiURL() string

func (*Host) ToDTO

func (host *Host) ToDTO() body.HostRead

func (*Host) ToVerboseDTO

func (host *Host) ToVerboseDTO() body.HostVerboseRead

type HttpProxyCreateParams

type HttpProxyCreateParams struct {
	Name         string
	CustomDomain *string
}

type HttpProxyUpdateParams

type HttpProxyUpdateParams struct {
	Name         string
	CustomDomain *string
}

type InitContainer

type InitContainer struct {
	Name    string   `bson:"name"`
	Image   string   `bson:"image"`
	Command []string `bson:"command"`
	Args    []string `bson:"args"`
}

type Job

type Job struct {
	ID      string                 `bson:"id"`
	UserID  string                 `bson:"userId"`
	Type    string                 `bson:"type"`
	Args    map[string]interface{} `bson:"args"`
	Version string                 `bson:"version"`

	CreatedAt  time.Time `bson:"createdAt"`
	LastRunAt  time.Time `bson:"lastRunAt,omitempty"`
	FinishedAt time.Time `bson:"finishedAt,omitempty"`
	RunAfter   time.Time `bson:"runAfter,omitempty"`

	Attempts int `bson:"attempts"`

	Status    string   `bson:"status" `
	ErrorLogs []string `bson:"errorLogs" `
}

func (*Job) HasArg

func (job *Job) HasArg(key string) bool

func (*Job) ToDTO

func (job *Job) ToDTO(statusMessage string) body.JobRead

ToDTO converts a Job to a body.JobRead DTO.

type JobUpdateParams

type JobUpdateParams struct {
	Status *string `bson:"status" json:"status"`
}

func (*JobUpdateParams) FromDTO

func (params *JobUpdateParams) FromDTO(jobUpdateDTO *body.JobUpdate)

type Jobs

type Jobs struct {
	Docker Docker `yaml:"docker"`
}

type Log

type Log struct {
	Source    string    `bson:"source"`
	Prefix    string    `bson:"prefix"`
	Line      string    `bson:"line"`
	CreatedAt time.Time `bson:"createdAt"`
}

type Notification

type Notification struct {
	ID      string                 `bson:"id"`
	UserID  string                 `bson:"userId"`
	Type    string                 `bson:"type"`
	Content map[string]interface{} `bson:"content"`

	CreatedAt   time.Time `bson:"createdAt"`
	ReadAt      time.Time `bson:"readAt,omitempty"`
	ToastedAt   time.Time `bson:"toastedAt,omitempty"`
	CompletedAt time.Time `bson:"completedAt,omitempty"`
	DeletedAt   time.Time `bson:"deletedAt,omitempty"`
}

func (*Notification) ToDTO

func (notification *Notification) ToDTO() body.NotificationRead

ToDTO converts a Notification to a body.NotificationRead DTO.

type NotificationCreateParams

type NotificationCreateParams struct {
	Type    string                 `json:"type"`
	Content map[string]interface{} `json:"content"`
}

type On

type On struct {
	Push             Push     `yaml:"push"`
	WorkflowDispatch struct{} `yaml:"workflow_dispatch"`
}

type Permissions

type Permissions struct {
	ChooseZone        bool `yaml:"chooseZone" structs:"chooseZone"`
	ChooseGPU         bool `yaml:"chooseGpu" structs:"chooseGpu"`
	UseCustomDomains  bool `yaml:"useCustomDomains" structs:"useCustomDomains"`
	UseGPUs           bool `yaml:"useGpus" structs:"useGpus"`
	UsePrivilegedGPUs bool `yaml:"usePrivilegedGpus" structs:"usePrivilegedGpus"`
	// If non nil then use explicit value, if nil then we allow use of vms (for backward compatibilty).
	// Only checked when creating a new VM, if a user already has a VM then we allow them to update it.
	UseVms *bool `yaml:"useVms,omitempty" structs:"useVms,omitempty"`
}

type PodDeleted

type PodDeleted struct {
	DeploymentName string `bson:"deploymentName"`
	PodName        string `bson:"podName"`
}

type Port

type Port struct {
	Name      string         `bson:"name"`
	Port      int            `bson:"port"`
	Protocol  string         `bson:"protocol"`
	HttpProxy *PortHttpProxy `bson:"httpProxy,omitempty"`
}

type PortCreateParams

type PortCreateParams struct {
	Name      string
	Port      int
	Protocol  string
	HttpProxy *HttpProxyCreateParams
}

type PortHttpProxy

type PortHttpProxy struct {
	Name         string        `bson:"name,omitempty"`
	CustomDomain *CustomDomain `bson:"customDomain,omitempty"`
}

type PortUpdateParams

type PortUpdateParams struct {
	Name      string
	Port      int
	Protocol  string
	HttpProxy *HttpProxyUpdateParams
}

type PublicKey

type PublicKey struct {
	Name string `bson:"name"`
	Key  string `bson:"key"`
}

type Push

type Push struct {
	Branches []string `yaml:"branches"`
}

type Quotas

type Quotas struct {
	CpuCores         float64 `yaml:"cpuCores" structs:"cpuCores"`
	RAM              float64 `yaml:"ram" structs:"ram"`
	DiskSize         float64 `yaml:"diskSize" structs:"diskSize"`
	Snapshots        int     `yaml:"snapshots" structs:"snapshots"`
	GpuLeaseDuration float64 `yaml:"gpuLeaseDuration" structs:"gpuLeaseDuration"` // in hours
	Gpus             int     `yaml:"gpus" structs:"gpus"`
}

func (*Quotas) ToDTO

func (q *Quotas) ToDTO() body.Quota

ToDTO converts a Quotas to a body.Quota DTO.

type ReplicaStatus

type ReplicaStatus struct {
	// DesiredReplicas is the number of replicas that the deployment should have.
	DesiredReplicas int `bson:"desiredReplicas"`
	// ReadyReplicas is the number of replicas that are ready.
	ReadyReplicas int `bson:"readyReplicas"`
	// AvailableReplicas is the number of replicas that are available.
	AvailableReplicas int `bson:"availableReplicas"`
	// UnavailableReplicas is the number of replicas that are unavailable.
	UnavailableReplicas int `bson:"unavailableReplicas"`
}

type RequestAllocationMode

type RequestAllocationMode string

RequestAllocationMode defines how GPUs should be allocated.

const (
	RequestAllocationMode_None       RequestAllocationMode = ""
	RequestAllocationMode_All        RequestAllocationMode = "All"
	RequestAllocationMode_ExactCount RequestAllocationMode = "ExactCount"
)

type RequestedGpu

type RequestedGpu struct {
	AllocationMode  RequestAllocationMode   `bson:"allocationMode"`
	Capacity        map[string]string       `bson:"capacity,omitempty"` // e.g. memory: "16Gi"
	Count           *int64                  `bson:"count,omitempty"`
	DeviceClassName string                  `bson:"deviceClassName"`
	Selectors       []string                `bson:"selectors,omitempty"`
	Config          *GpuDeviceConfiguration `bson:"config,omitempty"`
}

RequestedGpu describes the desired GPU configuration a workload requests.

type RequestedGpuCreate

type RequestedGpuCreate struct {
	RequestedGpu `mapstructure:",squash" json:",inline" bson:",inline"`
	Name         string `json:"name" bson:"name"`
}

type ResourceMigration

type ResourceMigration struct {
	ID         string `bson:"id"`
	ResourceID string `bson:"resourceId"`
	UserID     string `bson:"userId"`

	Type         string `bson:"type"`
	ResourceType string `bson:"resourceType"`
	Status       string `bson:"status"`

	Code *string `bson:"code"`

	CreatedAt time.Time  `bson:"createdAt"`
	DeletedAt *time.Time `bson:"deletedAt,omitempty"`

	UpdateOwner *ResourceMigrationUpdateOwner `bson:"updateOwner,omitempty"`
}

func (*ResourceMigration) ToDTO

ToDTO returns the resource migration to a body.ResourceMigrationDTO

type ResourceMigrationCreateParams

type ResourceMigrationCreateParams struct {
	Type         string      `bson:"type"`
	ResourceType string      `bson:"resourceType"`
	ResourceID   string      `bson:"resourceID"`
	Params       interface{} `bson:"params"`
}

type ResourceMigrationUpdateOwner

type ResourceMigrationUpdateOwner struct {
	NewOwnerID string
	OldOwnerID string
}

type ResourceMigrationUpdateOwnerParams

type ResourceMigrationUpdateOwnerParams struct {
	NewOwnerID string
	OldOwnerID string
}

type ResourceMigrationUpdateParams

type ResourceMigrationUpdateParams struct {
	Status string `bson:"status"`
}

func (ResourceMigrationUpdateParams) FromDTO

type Role

type Role struct {
	Name        string      `yaml:"name"`
	Description string      `yaml:"description"`
	IamGroup    string      `yaml:"iamGroup"`
	Permissions Permissions `yaml:"permissions"`
	Quotas      Quotas      `yaml:"quotas"`
}

func (*Role) ToDTO

func (r *Role) ToDTO(includeQuota bool) body2.Role

ToDTO converts a Role to a body.Role DTO.

type SM

type SM struct {
	ID      string `bson:"id"`
	OwnerID string `bson:"ownerId"`
	Zone    string `bson:"zone"`

	CreatedAt  time.Time `bson:"createdAt"`
	RepairedAt time.Time `bson:"repairedAt"`
	DeletedAt  time.Time `bson:"deletedAt"`

	Activities map[string]Activity `bson:"activities"`

	Subsystems SmSubsystems `bson:"subsystems"`
}

func (*SM) DoingActivity

func (sm *SM) DoingActivity(activity string) bool

DoingActivity returns true if the deployment is doing the given activity.

func (*SM) GetURL

func (sm *SM) GetURL(externalPort *int) *string

GetURL returns the URL of the storage manager If the K8s ingress does not exist, it will return nil, or if the ingress does not have a host, it will return nil.

func (*SM) ToDTO

func (sm *SM) ToDTO(externalPort *int) body.SmRead

ToDTO converts an SM to a body.SmRead DTO.

type SmCreateParams

type SmCreateParams struct {
	Zone string `json:"zone" bson:"zone"`
}

type SmJob

type SmJob struct {
	Name    string   `bson:"name"`
	Image   string   `bson:"image"`
	Command []string `bson:"command"`
	Args    []string `bson:"args"`
}

type SmK8s

type SmK8s struct {
	Namespace     k8sModels.NamespacePublic             `bson:"namespace"`
	DeploymentMap map[string]k8sModels.DeploymentPublic `bson:"deploymentMap,omitempty"`
	ServiceMap    map[string]k8sModels.ServicePublic    `bson:"serviceMap,omitempty"`
	IngressMap    map[string]k8sModels.IngressPublic    `bson:"ingressMap,omitempty"`
	PvMap         map[string]k8sModels.PvPublic         `bson:"pvMap,omitempty"`
	PvcMap        map[string]k8sModels.PvcPublic        `bson:"pvcMap,omitempty"`
}

func (*SmK8s) DeleteDeployment

func (k *SmK8s) DeleteDeployment(name string)

DeleteDeployment deletes the deployment from the DeploymentMap with the given name. It uses GetDeploymentMap to get the map to avoid nil pointer dereferences.

func (*SmK8s) DeleteIngress

func (k *SmK8s) DeleteIngress(name string)

DeleteIngress deletes the ingress from the IngressMap with the given name. It uses GetIngressMap to get the map to avoid nil pointer dereferences.

func (*SmK8s) DeletePV

func (k *SmK8s) DeletePV(name string)

DeletePV deletes the PV from the PvMap with the given name. It uses GetPvMap to get the map to avoid nil pointer dereferences.

func (*SmK8s) DeletePVC

func (k *SmK8s) DeletePVC(name string)

DeletePVC deletes the PVC from the PvcMap with the given name. It uses GetPvcMap to get the map to avoid nil pointer dereferences.

func (*SmK8s) DeleteService

func (k *SmK8s) DeleteService(name string)

DeleteService deletes the service from the ServiceMap with the given name. It uses GetServiceMap to get the map to avoid nil pointer dereferences.

func (*SmK8s) GetDeployment

func (k *SmK8s) GetDeployment(name string) *k8sModels.DeploymentPublic

GetDeployment returns the deployment with the given name. If a deployment with the given name does not exist, nil will be returned.

func (*SmK8s) GetDeploymentMap

func (k *SmK8s) GetDeploymentMap() map[string]k8sModels.DeploymentPublic

GetDeploymentMap returns the deployment map of the deployment. If the map is nil, it will be initialized before returning.

func (*SmK8s) GetIngress

func (k *SmK8s) GetIngress(name string) *k8sModels.IngressPublic

GetIngress returns the ingress with the given name. If an ingress with the given name does not exist, nil will be returned.

func (*SmK8s) GetIngressMap

func (k *SmK8s) GetIngressMap() map[string]k8sModels.IngressPublic

GetIngressMap returns the ingress map of the deployment. If the map is nil, it will be initialized before returning.

func (*SmK8s) GetNamespace

func (k *SmK8s) GetNamespace() *k8sModels.NamespacePublic

GetNamespace returns the namespace of the deployment.

func (*SmK8s) GetPV

func (k *SmK8s) GetPV(name string) *k8sModels.PvPublic

GetPV returns the PV with the given name. If a PV with the given name does not exist, nil will be returned.

func (*SmK8s) GetPVC

func (k *SmK8s) GetPVC(name string) *k8sModels.PvcPublic

GetPVC returns the PVC with the given name. If a PVC with the given name does not exist, nil will be returned.

func (*SmK8s) GetPvMap

func (k *SmK8s) GetPvMap() map[string]k8sModels.PvPublic

GetPvMap returns the pv map of the deployment. If the map is nil, it will be initialized before returning.

func (*SmK8s) GetPvcMap

func (k *SmK8s) GetPvcMap() map[string]k8sModels.PvcPublic

GetPvcMap returns the pvc map of the deployment. If the map is nil, it will be initialized before returning.

func (*SmK8s) GetService

func (k *SmK8s) GetService(name string) *k8sModels.ServicePublic

GetService returns the service with the given name. If a service with the given name does not exist, nil will be returned.

func (*SmK8s) GetServiceMap

func (k *SmK8s) GetServiceMap() map[string]k8sModels.ServicePublic

GetServiceMap returns the service map of the deployment. If the map is nil, it will be initialized before returning.

type SmSubsystems

type SmSubsystems struct {
	K8s    DeploymentK8s    `bson:"k8s"`
	Harbor DeploymentHarbor `bson:"harbor"`
}

type SmVolume

type SmVolume struct {
	Name       string `bson:"name"`
	Init       bool   `bson:"init"`
	AppPath    string `bson:"appPath"`
	ServerPath string `bson:"serverPath"`
}

type Snapshot

type Snapshot struct {
	ID         string
	VmID       string
	Name       string
	ParentName *string
	CreatedAt  time.Time
	State      string
	Current    bool
}

type SnapshotV2

type SnapshotV2 struct {
	ID        string
	Name      string
	Status    string
	CreatedAt time.Time
}

func (*SnapshotV2) ToDTOv2

func (sc *SnapshotV2) ToDTOv2() body.VmSnapshotRead

ToDTOv2 converts a Snapshot to a body.VmSnapshotRead.

type Source

type Source struct {
	UserID *string `bson:"userId,omitempty"`
	IP     *string `bson:"ip"`
}

type Steps

type Steps struct {
	Name string `yaml:"name"`
	Uses string `yaml:"uses"`
	With With   `yaml:"with,omitempty"`
}

type Subsystems

type Subsystems struct {
	K8s VmK8s `bson:"k8s"`
}

type Team

type Team struct {
	ID          string    `bson:"id"`
	Name        string    `bson:"name"`
	Description string    `bson:"description"`
	OwnerID     string    `bson:"ownerId"`
	CreatedAt   time.Time `bson:"createdAt"`
	UpdatedAt   time.Time `bson:"updatedAt"`

	ResourceMap map[string]TeamResource `bson:"resourceMap"`
	MemberMap   map[string]TeamMember   `bson:"memberMap"`
}

func (*Team) AddMember

func (t *Team) AddMember(member TeamMember)

func (*Team) AddResource

func (t *Team) AddResource(resource TeamResource)

func (*Team) GetID

func (t *Team) GetID() string

func (*Team) GetMember

func (t *Team) GetMember(id string) *TeamMember

func (*Team) GetMemberMap

func (t *Team) GetMemberMap() map[string]TeamMember

func (*Team) GetResource

func (t *Team) GetResource(id string) *TeamResource

func (*Team) GetResourceMap

func (t *Team) GetResourceMap() map[string]TeamResource

func (*Team) HasMember

func (t *Team) HasMember(id string) bool

func (*Team) HasResource

func (t *Team) HasResource(id string) bool

func (*Team) RemoveMember

func (t *Team) RemoveMember(id string)

func (*Team) RemoveResource

func (t *Team) RemoveResource(id string)

func (*Team) ToDTO

func (t *Team) ToDTO(getMember func(*TeamMember) *body.TeamMember, getResourceName func(*TeamResource) *string) body.TeamRead

ToDTO converts a Team to a body.TeamRead DTO.

type TeamCreateParams

type TeamCreateParams struct {
	Name        string
	Description string
	ResourceMap map[string]TeamResource
	MemberMap   map[string]TeamMember
}

func (*TeamCreateParams) FromDTO

func (params *TeamCreateParams) FromDTO(teamCreateDTO *body.TeamCreate, ownerID string, getResourceFunc func(string) *TeamResource, getMemberFunc func(*body.TeamMemberCreate) *TeamMember)

FromDTO converts a body.TeamCreate DTO to a NotificationCreateParams.

type TeamJoinParams

type TeamJoinParams struct {
	InvitationCode string
}

func (*TeamJoinParams) FromDTO

func (params *TeamJoinParams) FromDTO(teamJoinDTO *body.TeamJoin)

FromDTO converts a body.TeamJoin DTO to a JoinParams.

type TeamMember

type TeamMember struct {
	// ID is the same as UserID
	ID           string `bson:"id"`
	TeamRole     string `bson:"teamRole"`
	MemberStatus string `bson:"memberStatus"`

	AddedAt  time.Time `bson:"addedAt"`
	JoinedAt time.Time `bson:"joinedAt"`

	InvitationCode string `bson:"invitationCode"`
}

type TeamResource

type TeamResource struct {
	ID      string    `bson:"id"`
	Type    string    `bson:"type"`
	AddedAt time.Time `bson:"addedAt"`
}

type TeamUpdateParams

type TeamUpdateParams struct {
	Name        *string
	Description *string
	MemberMap   *map[string]TeamMember
	ResourceMap *map[string]TeamResource
}

func (*TeamUpdateParams) FromDTO

func (params *TeamUpdateParams) FromDTO(teamUpdateDTO *body.TeamUpdate, owner *TeamMember, getResourceFunc func(string) *TeamResource, getMemberFunc func(*body.TeamMemberUpdate) *TeamMember)

FromDTO converts a body.TeamUpdate DTO to an UpdateParams.

type User

type User struct {
	ID        string   `bson:"id"`
	Username  string   `bson:"username"`
	FirstName string   `bson:"firstName"`
	LastName  string   `bson:"lastName"`
	Email     string   `bson:"email"`
	Gravatar  Gravatar `bson:"gravatar"`

	IsAdmin       bool          `bson:"isAdmin"`
	EffectiveRole EffectiveRole `bson:"effectiveRole"`

	PublicKeys []PublicKey `bson:"publicKeys,omitempty"`
	ApiKeys    []ApiKey    `bson:"apiKeys,omitempty"`
	UserData   []UserData  `bson:"userData,omitempty"`

	LastAuthenticatedAt time.Time `bson:"lastAuthenticatedAt"`
}

func (*User) ToDTO

func (user *User) ToDTO(effectiveRole *Role, usage *UserUsage, storageURL *string) body.UserRead

ToDTO converts a User to a body.UserRead DTO.

type UserData

type UserData struct {
	Key   string `bson:"key"`
	Value string `bson:"value"`
}

type UserSynchronizeParams

type UserSynchronizeParams struct {
	Username      string
	FirstName     string
	LastName      string
	Email         string
	IsAdmin       bool
	EffectiveRole *EffectiveRole
}

type UserUpdateParams

type UserUpdateParams struct {
	ApiKeys    *[]ApiKey
	PublicKeys *[]PublicKey
	UserData   *[]UserData
}

func (UserUpdateParams) FromDTO

func (params UserUpdateParams) FromDTO(userUpdateDTO *body.UserUpdate, currentApiKeys []ApiKey) UserUpdateParams

FromDTO converts a body.UserUpdate DTO to a UserUpdateParams.

type UserUsage

type UserUsage struct {
	CpuCores  float64 `bson:"cpuCores"`
	RAM       float64 `bson:"ram"`
	DiskSize  int     `bson:"diskSize"`
	Snapshots int     `bson:"snapshots"`
	Gpus      int     `bson:"gpus"`
}

func (*UserUsage) ToDTO

func (usage *UserUsage) ToDTO() body.Usage

ToDTO converts a Usage to a body.Usage DTO.

type VM

type VM struct {
	ID      string `bson:"id"`
	Name    string `bson:"name"`
	Version string `bson:"version"`
	Zone    string `bson:"zone"`
	OwnerID string `bson:"ownerId"`

	CreatedAt  time.Time `bson:"createdAt"`
	UpdatedAt  time.Time `bson:"updatedAt,omitempty"`
	RepairedAt time.Time `bson:"repairedAt,omitempty"`
	DeletedAt  time.Time `bson:"deletedAt,omitempty"`
	AccessedAt time.Time `bson:"accessedAt"`

	NeverStale bool `bson:"neverStale"`

	SshPublicKey string          `bson:"sshPublicKey"`
	PortMap      map[string]Port `bson:"portMap"`
	Specs        VmSpecs         `bson:"specs"`

	Subsystems Subsystems          `bson:"subsystems"`
	Activities map[string]Activity `bson:"activities"`

	// Host is the host where the VM is running
	// It is set by the status updater worker
	Host *VmHost `bson:"host,omitempty"`
	// Status is the current status of a VM instance
	// It is set by the status updater worker
	Status string `bson:"status"`
}

func (*VM) BeingCreated

func (vm *VM) BeingCreated() bool

func (*VM) BeingDeleted

func (vm *VM) BeingDeleted() bool

func (*VM) DoingActivity

func (vm *VM) DoingActivity(activity string) bool

func (*VM) DoingOneOfActivities

func (vm *VM) DoingOneOfActivities(activities []string) bool

func (*VM) GetExternalPort

func (vm *VM) GetExternalPort(privatePort int, protocol string) *int

func (*VM) GetHttpProxyURL

func (vm *VM) GetHttpProxyURL(name string, externalPort *int) *string

GetHttpProxyURL returns the URL of a VM's HTTP proxy. If the K8s ingress does not exist, it will return nil, or if the ingress does not have a host, it will return nil.

func (*VM) Ready

func (vm *VM) Ready() bool

func (*VM) ToDTOv2

func (vm *VM) ToDTOv2(gpuLease *GpuLease, teams []string, externalPort *int, sshConnectionString *string) body.VmRead

ToDTOv2 converts a VM to a body.VmRead.

type VmActionParams

type VmActionParams struct {
	Action string
}

func (VmActionParams) FromDTOv2

FromDTOv2 converts a dto.Action to a VmActionParams.

type VmCreateParams

type VmCreateParams struct {
	Name string
	Zone string

	SshPublicKey string
	PortMap      map[string]PortCreateParams

	CpuCores int
	RAM      int
	DiskSize int

	NeverStale bool
}

func (VmCreateParams) FromDTOv2

func (p VmCreateParams) FromDTOv2(dto *body.VmCreate, fallbackZone *string) VmCreateParams

FromDTOv2 converts a body.VmCreate to a NotificationCreateParams.

type VmHost

type VmHost struct {
	Name string `bson:"name"`
}

type VmK8s

type VmK8s struct {
	Namespace        k8sModels.NamespacePublic                `bson:"namespace"`
	DeploymentMap    map[string]k8sModels.DeploymentPublic    `bson:"deploymentMap,omitempty"`
	ServiceMap       map[string]k8sModels.ServicePublic       `bson:"serviceMap,omitempty"`
	IngressMap       map[string]k8sModels.IngressPublic       `bson:"ingressMap,omitempty"`
	SecretMap        map[string]k8sModels.SecretPublic        `bson:"secretMap,omitempty"`
	NetworkPolicyMap map[string]k8sModels.NetworkPolicyPublic `bson:"networkPolicyMap,omitempty"`

	// Deprecated: VmMap is deprecated and will be removed in a future release
	// Use the VM field instead
	VmMap map[string]k8sModels.VmPublic `bson:"vmMap,omitempty"`

	VM            k8sModels.VmPublic                    `bson:"vm"`
	PvcMap        map[string]k8sModels.PvcPublic        `bson:"pvcMap,omitempty"`
	PvMap         map[string]k8sModels.PvPublic         `bson:"pvMap,omitempty"`
	VmSnapshotMap map[string]k8sModels.VmSnapshotPublic `bson:"vmSnapshotMap,omitempty"`
}

func (*VmK8s) GetDeployment

func (k8s *VmK8s) GetDeployment(name string) *k8sModels.DeploymentPublic

GetDeployment returns the deployment of the VM. If the deployment does not exist, nil is returned

func (*VmK8s) GetDeploymentMap

func (k8s *VmK8s) GetDeploymentMap() map[string]k8sModels.DeploymentPublic

GetDeploymentMap returns the deployment map of the VM. If the map is nil, it will be initialized before returning

func (*VmK8s) GetIngress

func (k8s *VmK8s) GetIngress(name string) *k8sModels.IngressPublic

GetIngress returns the ingress of the VM. If the ingress does not exist, nil is returned

func (*VmK8s) GetIngressMap

func (k8s *VmK8s) GetIngressMap() map[string]k8sModels.IngressPublic

GetIngressMap returns the ingress map of the VM. If the map is nil, it will be initialized before returning

func (*VmK8s) GetNetworkPolicy

func (k8s *VmK8s) GetNetworkPolicy(name string) *k8sModels.NetworkPolicyPublic

GetNetworkPolicy returns the network policy of the VM. If the network policy does not exist, nil is returned

func (*VmK8s) GetNetworkPolicyMap

func (k8s *VmK8s) GetNetworkPolicyMap() map[string]k8sModels.NetworkPolicyPublic

GetNetworkPolicyMap returns the network policy map of the VM. If the map is nil, it will be initialized before returning

func (*VmK8s) GetPV

func (k8s *VmK8s) GetPV(name string) *k8sModels.PvPublic

GetPV returns the PV of the VM. If the PV does not exist, nil is returned

func (*VmK8s) GetPVC

func (k8s *VmK8s) GetPVC(name string) *k8sModels.PvcPublic

GetPVC returns the PVC of the VM. If the PVC does not exist, nil is returned

func (*VmK8s) GetPvMap

func (k8s *VmK8s) GetPvMap() map[string]k8sModels.PvPublic

GetPvMap returns the PV map of the VM. If the map is nil, it will be initialized before returning

func (*VmK8s) GetPvcMap

func (k8s *VmK8s) GetPvcMap() map[string]k8sModels.PvcPublic

GetPvcMap returns the PVC map of the VM. If the map is nil, it will be initialized before returning

func (*VmK8s) GetSecret

func (k8s *VmK8s) GetSecret(name string) *k8sModels.SecretPublic

GetSecret returns the secret of the VM. If the secret does not exist, nil is returned

func (*VmK8s) GetSecretMap

func (k8s *VmK8s) GetSecretMap() map[string]k8sModels.SecretPublic

GetSecretMap returns the secret map of the VM. If the map is nil, it will be initialized before returning

func (*VmK8s) GetService

func (k8s *VmK8s) GetService(name string) *k8sModels.ServicePublic

GetService returns the service of the VM. If the service does not exist, nil is returned

func (*VmK8s) GetServiceMap

func (k8s *VmK8s) GetServiceMap() map[string]k8sModels.ServicePublic

GetServiceMap returns the service map of the VM. If the map is nil, it will be initialized before returning

func (*VmK8s) GetVmSnapshotByID

func (k8s *VmK8s) GetVmSnapshotByID(id string) *k8sModels.VmSnapshotPublic

GetVmSnapshotByID returns a snapshot in the VM by ID. If the snapshot does not exist, nil is returned

func (*VmK8s) GetVmSnapshotByName

func (k8s *VmK8s) GetVmSnapshotByName(name string) *k8sModels.VmSnapshotPublic

GetVmSnapshotByName returns a snapshot in the VM by name. If the snapshot does not exist, nil is returned

func (*VmK8s) GetVmSnapshotMap

func (k8s *VmK8s) GetVmSnapshotMap() map[string]k8sModels.VmSnapshotPublic

GetVmSnapshotMap returns the vm snapshot map of the VM. If the map is nil, it will be initialized before returning

type VmPort

type VmPort struct {
	PublicPort int          `bson:"publicPort"`
	Zone       string       `bson:"zone"`
	Lease      *VmPortLease `bson:"lease"`
}

type VmPortLease

type VmPortLease struct {
	VmID        string `bson:"vmId"`
	PrivatePort int    `bson:"privatePort"`
}

type VmSpecs

type VmSpecs struct {
	CpuCores int `json:"cpuCores"`
	RAM      int `json:"ram"`
	DiskSize int `json:"diskSize"`
}

type VmStatus

type VmStatus struct {
	Name            string `bson:"name"`
	PrintableStatus string `bson:"printableStatus"`
}

type VmUpdateOwnerParams

type VmUpdateOwnerParams struct {
	NewOwnerID    string
	OldOwnerID    string
	MigrationCode *string
}

type VmUpdateParams

type VmUpdateParams struct {
	Name       *string
	OwnerID    *string
	SnapshotID *string
	PortMap    *map[string]PortUpdateParams
	CpuCores   *int
	RAM        *int
	NeverStale *bool
}

func (VmUpdateParams) FromDTOv2

func (p VmUpdateParams) FromDTOv2(dto *body.VmUpdate) VmUpdateParams

FromDTOv2 converts a body.VmUpdate to a UpdateParams.

type VmUsage

type VmUsage struct {
	CpuCores int `bson:"cpuCores"`
	RAM      int `bson:"ram"`
	DiskSize int `bson:"diskSize"`
}

type VmiStatus

type VmiStatus struct {
	Name string  `bson:"name"`
	Host *string `bson:"host,omitempty"`
}

type With

type With struct {
	Registry string `yaml:"registry,omitempty"`
	Username string `yaml:"username,omitempty"`
	Password string `yaml:"password,omitempty"`
	Push     bool   `yaml:"push,omitempty"`
	Tags     string `yaml:"tags,omitempty"`
}

type WorkerStatus

type WorkerStatus struct {
	Name       string    `bson:"name"`
	Status     string    `bson:"status"`
	ReportedAt time.Time `bson:"reportedAt"`
}

func (*WorkerStatus) ToDTO

func (ws *WorkerStatus) ToDTO() body.WorkerStatusRead

ToDTO converts a WorkerStatus to a body.WorkerStatusRead DTO.

type Zone

type Zone struct {
	Name string `json:"name" bson:"name"`
}

Jump to

Keyboard shortcuts

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