models

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WorkspaceConfigSourceGit      = "git"
	WorkspaceConfigSourceTemplate = "template"
)
View Source
const WorkspaceStatusDeleting = "deleting"
View Source
const WorkspaceStatusError = "error"
View Source
const WorkspaceStatusRunning = "running"
View Source
const WorkspaceStatusStarting = "starting"

workspace status

View Source
const WorkspaceStatusStopped = "stopped"
View Source
const WorkspaceStatusStopping = "stopping"

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(password string) (string, error)

func RemoveExpiredAuthorizationCodes

func RemoveExpiredAuthorizationCodes() error

remove expired authorization codes

func ValidatePassword

func ValidatePassword(password string) error

Types

type AuthorizationCode

type AuthorizationCode struct {
	ID        uint   `gorm:"primarykey"`
	Code      string `gorm:"size:255"`
	TokenID   uint
	Token     *Token
	ExpiresAt time.Time
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func GenerateAuthorizationCode

func GenerateAuthorizationCode(token Token, expiration time.Time) (ac AuthorizationCode, err error)

generate authorization code

type GitWorkspaceSource

type GitWorkspaceSource struct {
	ID             uint           `gorm:"primarykey" json:"id"`
	RepositoryURL  string         `gorm:"type:text;not null;" json:"repository_url"`
	RefName        string         `gorm:"size:255; not null;" json:"ref_name"`
	ConfigFilePath string         `gorm:"type:text;" json:"config_file_relative_path"`
	Files          string         `gorm:"type:text;" json:"-"`
	CreatedAt      time.Time      `json:"-"`
	UpdatedAt      time.Time      `json:"-"`
	DeletedAt      gorm.DeletedAt `gorm:"index" json:"-"`
}

func (*GitWorkspaceSource) GetConfigFileAbsPath

func (gws *GitWorkspaceSource) GetConfigFileAbsPath() (p string, err error)

type Group

type Group struct {
	gorm.Model
	ID   uint   `gorm:"primarykey"`
	Name string `gorm:"size:255;unique"`
}

type Runner

type Runner struct {
	ID            uint           `gorm:"primarykey" json:"id"`
	Name          string         `gorm:"size:255;unique;not null;" json:"name"`
	Token         string         `gorm:"size:255;unique;not null;" json:"-"`
	Port          uint           `gorm:"default:0;" json:"-"`
	Type          string         `gorm:"size:255;" json:"type"`
	Restricted    bool           `gorm:"default:false;" json:"-"`
	AllowedGroups []Group        `gorm:"many2many:runner_allowed_groups;" json:"-"`
	UsePublicUrl  bool           `gorm:"default:false;" json:"use_public_url"`
	PublicUrl     string         `gorm:"type:text;" json:"public_url"`
	LastContact   *time.Time     `json:"last_contact"`
	CreatedAt     time.Time      `json:"-"`
	UpdatedAt     time.Time      `json:"-"`
	DeletedAt     gorm.DeletedAt `gorm:"index" json:"-"`
}

type Token

type Token struct {
	gorm.Model
	ID             uint   `gorm:"primarykey"`
	Token          string `gorm:"size:255;unique;"`
	ExpirationDate *time.Time
	UserID         uint
	User           User `gorm:"constraint:OnDelete:CASCADE;"`
}

func CreateToken

func CreateToken(user User, duration time.Duration) (Token, error)

type User

type User struct {
	ID            uint           `gorm:"primarykey" json:"-"`
	Email         string         `gorm:"size:255; unique; not null;" json:"email"`
	Password      string         `gorm:"not null;" json:"-"`
	FirstName     string         `gorm:"size:255;" json:"first_name"`
	LastName      string         `gorm:"size:255;" json:"last_name"`
	Groups        []Group        `gorm:"many2many:user_groups;" json:"groups"`
	SshPrivateKey string         `gorm:"not null;" json:"-"`
	SshPublicKey  string         `gorm:"not null;" json:"-"`
	IsSuperuser   bool           `gorm:"column:is_superuser; default:false" json:"is_superuser"`
	CreatedAt     time.Time      `json:"-"`
	UpdatedAt     time.Time      `json:"-"`
	DeletedAt     gorm.DeletedAt `gorm:"index" json:"-"`
}

func (*User) BeforeSave

func (u *User) BeforeSave(tx *gorm.DB) (err error)

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

type Workspace

type Workspace struct {
	ID                   uint                      `gorm:"primarykey" json:"id"`
	Name                 string                    `gorm:"size:255; not null;" json:"name"`
	UserID               uint                      `json:"-"`
	User                 *User                     `gorm:"constraint:OnDelete:CASCADE;" json:"user"`
	Status               string                    `gorm:"size:30; not null;" json:"status"`
	Type                 string                    `gorm:"size:255; not null;" json:"type"`
	RunnerID             uint                      `json:"-"`
	Runner               *Runner                   `gorm:"constraint:OnDelete:CASCADE;" json:"runner"`
	ConfigSource         string                    `gorm:"size:20; not null;" json:"config_source"` // template/git
	TemplateVersionID    *uint                     `json:"-"`
	TemplateVersion      *WorkspaceTemplateVersion `gorm:"constraint:OnDelete:CASCADE;" json:"template_version"`
	GitSourceID          *uint                     `json:"-"`
	GitSource            *GitWorkspaceSource       `gorm:"constraint:OnDelete:CASCADE;" json:"git_source"`
	EnvironmentVariables []string                  `gorm:"serializer:json" json:"environment_variables"`
	CreatedAt            time.Time                 `json:"created_at"`
	UpdatedAt            time.Time                 `json:"updated_at"`
	DeletedAt            gorm.DeletedAt            `gorm:"index" json:"-"`
}

func (*Workspace) AppendLogs

func (w *Workspace) AppendLogs(logs string) error

func (*Workspace) ClearLogs

func (w *Workspace) ClearLogs() error

func (*Workspace) GetDefaultEnvironmentVariables

func (w *Workspace) GetDefaultEnvironmentVariables() []string

Retrieve list of environement variables to exported by default to workspace This variables are informations related to workspace such as workspace name, owner email, first name and last name

func (*Workspace) GetLogsFilePath

func (w *Workspace) GetLogsFilePath() (string, error)

func (*Workspace) RetrieveLogs

func (w *Workspace) RetrieveLogs() (string, error)

type WorkspaceContainer

type WorkspaceContainer struct {
	ID                uint           `gorm:"primarykey" json:"-"`
	WorkspaceID       uint           `json:"-"`
	Workspace         Workspace      `gorm:"constraint:OnDelete:CASCADE;" json:"-"`
	ContainerID       string         `gorm:"size:255" json:"container_id"`
	ContainerName     string         `gorm:"size:255" json:"container_name"`
	ContainerImage    string         `gorm:"size:255" json:"container_image"`
	ContainerUserID   uint           `json:"container_user_id"`
	ContainerUserName string         `gorm:"size:255" json:"container_user_name"`
	AgentLastContact  *time.Time     `json:"agent_last_contact"`
	WorkspacePath     string         `gorm:"size:255" json:"workspace_path"`
	CreatedAt         time.Time      `json:"created_at"`
	UpdatedAt         time.Time      `json:"updated_at"`
	DeletedAt         gorm.DeletedAt `gorm:"index" json:"-"`
}

type WorkspaceContainerPort

type WorkspaceContainerPort struct {
	ID          uint               `gorm:"primarykey" json:"-"`
	ContainerID uint               `json:"-"`
	Container   WorkspaceContainer `gorm:"constraint:OnDelete:CASCADE;" json:"-"`
	ServiceName string             `gorm:"size:255; not null;" json:"service_name"`
	PortNumber  uint               `gorm:"not null;" json:"port_number"`
	Public      bool               `gorm:"default:false;" json:"public"`
	CreatedAt   time.Time          `json:"created_at"`
	UpdatedAt   time.Time          `json:"updated_at"`
	DeletedAt   gorm.DeletedAt     `gorm:"index" json:"-"`
}

type WorkspaceTemplate

type WorkspaceTemplate struct {
	gorm.Model
	ID          uint   `gorm:"primarykey"`
	Name        string `gorm:"size:255;unique;not null;"`
	Type        string `gorm:"size:255;"`
	Description string
	Icon        string `gorm:"type:text;"`
}

type WorkspaceTemplateVersion

type WorkspaceTemplateVersion struct {
	gorm.Model
	ID             uint `gorm:"primarykey"`
	TemplateID     uint
	Template       *WorkspaceTemplate `gorm:"constraint:OnDelete:CASCADE;not null;"`
	Name           string             `gorm:"size:255;not null;"`
	ConfigFilePath string             `gorm:"type:text;" json:"config_file_relative_path"`
	Files          string             `gorm:"type:text;not null;"`
}

func (*WorkspaceTemplateVersion) GetConfigFileAbsPath

func (wtv *WorkspaceTemplateVersion) GetConfigFileAbsPath() (p string, err error)

Jump to

Keyboard shortcuts

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