models

package
v4.20.5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const RevisionAnnotation = "deployment.kubernetes.io/revision"

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	ID int `json:"id" gorm:"primaryKey;"`

	Token string `json:"token" gorm:"unique;size:255;not null;"`

	Usage     string    `json:"usage" gorm:"size:50;"`
	Email     string    `json:"email" gorm:"index;not null;default:'';"`
	ExpiredAt time.Time `json:"expired_at"`

	LastUsedAt sql.NullTime `json:"last_used_at"`

	UserInfo string `json:"-"`

	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at"`
}

func NewAccessToken

func NewAccessToken(usage string, expiredAt time.Time, user *contracts.UserInfo) *AccessToken

func (*AccessToken) Expired

func (at *AccessToken) Expired() bool

Expired token is expired.

func (*AccessToken) GetUserInfo

func (at *AccessToken) GetUserInfo() contracts.UserInfo

GetUserInfo return token userinfo.

func (*AccessToken) ProtoTransform

func (at *AccessToken) ProtoTransform() *types.AccessTokenModel

type CacheLock

type CacheLock struct {
	Key        string `gorm:"size:255;not null;primaryKey;"`
	Owner      string `gorm:"size:255;not null;"`
	Expiration int64  `gorm:"type:int;not null;"`
}

type Changelog

type Changelog struct {
	ID int `json:"id" gorm:"primaryKey;"`

	Version  int    `json:"version" gorm:"not null;default:1;type:integer;index:idx_projectid_config_changed_deleted_at_version,priority:4;"`
	Username string `json:"username" gorm:"size:100;not null;comment:修改人"`
	Manifest string `json:"manifest" gorm:"type:longtext;"`
	Config   string `json:"config" gorm:"type:text;commit:用户提交的配置"`

	ConfigType       string     `json:"config_type" gorm:"size:255;nullable;"`
	GitBranch        string     `json:"git_branch" gorm:"not null;size:255;"`
	GitCommit        string     `json:"git_commit" gorm:"not null;size:255;"`
	DockerImage      string     `json:"docker_image" gorm:"not null;size:255;default:''"`
	EnvValues        string     `json:"env_values" gorm:"type:text;nullable;comment:可用的环境变量值"`
	ExtraValues      string     `json:"extra_values" gorm:"type:text;nullable;comment:用户表单传入的额外值"`
	FinalExtraValues string     `json:"final_extra_values" gorm:"type:text;nullable;comment:用户表单传入的额外值 + 系统默认的额外值"`
	GitCommitWebUrl  string     `json:"git_commit_web_url" gorm:"size:255;nullable;"`
	GitCommitTitle   string     `json:"git_commit_title" gorm:"size:255;nullable;"`
	GitCommitAuthor  string     `json:"git_commit_author" gorm:"size:255;nullable;"`
	GitCommitDate    *time.Time `json:"git_commit_date"`

	ConfigChanged bool `json:"config_changed" gorm:"index:idx_projectid_config_changed_deleted_at_version,priority:2;"`

	ProjectID    int `json:"project_id" gorm:"not null;default:0;index:idx_projectid_config_changed_deleted_at_version,priority:1;"`
	GitProjectID int `json:"git_project_id" gorm:"not null;default:0;"`

	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index:idx_projectid_config_changed_deleted_at_version,priority:3;"`

	Project    Project
	GitProject GitProject
}

func (*Changelog) ProtoTransform

func (c *Changelog) ProtoTransform() *types.ChangelogModel

type DBCache

type DBCache struct {
	Key       string    `gorm:"size:255;not null;primaryKey;"`
	Value     string    `json:"value"`
	ExpiredAt time.Time `json:"expired_at"`
}

func (DBCache) TableName

func (c DBCache) TableName() string

type Event

type Event struct {
	ID int `json:"id" gorm:"primaryKey;"`

	Action   uint8  `json:"action" gorm:"type:tinyint;not null;default:0;index;"`
	Username string `json:"username" gorm:"size:255;not null;default:'';comment:用户名称"`
	Message  string `json:"message" gorm:"size:255;not null;default:'';"`

	Old      string `json:"old" gorm:"type:longtext;"`
	New      string `json:"new" gorm:"type:longtext;"`
	Duration string `json:"duration" gorm:"not null;default:''"`

	FileID *int `json:"file_id" gorm:"nullable;"`

	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at"`

	File *File
}

func (*Event) ProtoTransform

func (e *Event) ProtoTransform() *types.EventModel

type File

type File struct {
	ID int `json:"id" gorm:"primaryKey;"`

	UploadType contracts.UploadType `json:"upload_type" gorm:"size:100;not null;default:'local'"`
	Path       string               `json:"path" gorm:"size:255;not null;comment:文件全路径"`
	Size       uint64               `json:"size" gorm:"not null;default:0;comment:文件大小"`
	Username   string               `json:"username" gorm:"size:255;not null;default:'';comment:用户名称"`

	Namespace     string `json:"namespace" gorm:"size:100;not null;default:'';"`
	Pod           string `json:"pod" gorm:"size:100;not null;default:'';"`
	Container     string `json:"container" gorm:"size:100;not null;default:'';"`
	ContainerPath string `json:"container_path" gorm:"size:255;not null;default:'';comment:容器中的文件路径"`

	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at"`
}

func (*File) DeleteFile

func (f *File) DeleteFile()

func (*File) ProtoTransform

func (f *File) ProtoTransform() *types.FileModel

func (*File) Uploader

func (f *File) Uploader() (up contracts.Uploader)

type GitProject

type GitProject struct {
	ID int `json:"id" gorm:"primaryKey;"`

	DefaultBranch string `json:"default_branch" gorm:"type:varchar(255);not null;default:'';"`
	Name          string `json:"name" gorm:"type:varchar(255);not null;default:'';"`
	GitProjectId  int    `json:"git_project_id" gorm:"not null;type:integer;default:0;"`
	Enabled       bool   `json:"enabled" gorm:"not null;default:false;"`
	GlobalEnabled bool   `json:"global_enabled" gorm:"not null;default:false;"`
	GlobalConfig  string `json:"global_config" gorm:"type:longtext"`

	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at"`
}

func (*GitProject) GlobalMarsConfig

func (g *GitProject) GlobalMarsConfig() *mars.Config

func (GitProject) PrettyYaml

func (g GitProject) PrettyYaml() string

func (*GitProject) ProtoTransform

func (g *GitProject) ProtoTransform() *types.GitProjectModel

type Namespace

type Namespace struct {
	ID int `json:"id" gorm:"primaryKey;"`

	Name             string `json:"name" gorm:"size:100;not null;comment:项目空间名"`
	ImagePullSecrets string `json:"image_pull_secrets" gorm:"size:255;not null;default:'';comment:项目空间拉取镜像的secrets,数组"`

	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index;"`

	Projects []Project
}

func (*Namespace) GetImagePullSecrets

func (ns *Namespace) GetImagePullSecrets() []*types.ImagePullSecret

func (*Namespace) ImagePullSecretsArray

func (ns *Namespace) ImagePullSecretsArray() []string

func (*Namespace) ProtoTransform

func (ns *Namespace) ProtoTransform() *types.NamespaceModel

type Project

type Project struct {
	ID int `json:"id" gorm:"primaryKey;"`

	Name             string `json:"name" gorm:"size:100;not null;comment:项目名"`
	GitProjectId     int    `json:"git_project_id" gorm:"not null;type:integer;"`
	GitBranch        string `json:"git_branch" gorm:"not null;size:255;"`
	GitCommit        string `json:"git_commit" gorm:"not null;size:255;"`
	Config           string `json:"config"`
	OverrideValues   string `json:"override_values"`
	DockerImage      string `json:"docker_image" gorm:"not null;size:255;default:''"`
	PodSelectors     string `json:"pod_selectors" gorm:"type:text;nullable;"`
	NamespaceId      int    `json:"namespace_id" gorm:"index:idx_namespace_id_deleted_at,priority:1;"`
	Atomic           bool   `json:"atomic"`
	DeployStatus     uint8  `json:"deploy_status" gorm:"not null;default:0"`
	EnvValues        string `json:"env_values" gorm:"type:text;nullable;comment:可用的环境变量值"`
	ExtraValues      string `json:"extra_values" gorm:"type:longtext;nullable;comment:用户表单传入的额外值"`
	FinalExtraValues string `json:"final_extra_values" gorm:"type:longtext;nullable;comment:用户表单传入的额外值 + 系统默认的额外值"`
	Version          int    `json:"version" gorm:"type:int;not null;default:1;"`

	ConfigType string `json:"config_type" gorm:"size:255;nullable;"`
	Manifest   string `json:"manifest" gorm:"type:longtext;"`

	GitCommitWebUrl string     `json:"git_commit_web_url" gorm:"size:255;nullable;"`
	GitCommitTitle  string     `json:"git_commit_title" gorm:"size:255;nullable;"`
	GitCommitAuthor string     `json:"git_commit_author" gorm:"size:255;nullable;"`
	GitCommitDate   *time.Time `json:"git_commit_date"`

	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index:idx_namespace_id_deleted_at,priority:2;"`

	Namespace Namespace
}

func (*Project) GetAllPodMetrics

func (project *Project) GetAllPodMetrics() []v1beta1.PodMetrics

func (*Project) GetAllPods

func (project *Project) GetAllPods() SortStatePod

func (*Project) GetEnvValues

func (project *Project) GetEnvValues() (res map[string]any)

func (*Project) GetExtraValues

func (project *Project) GetExtraValues() (res []*types.ExtraValue)

func (*Project) GetPodSelectors

func (project *Project) GetPodSelectors() []string

GetPodSelectors 不仅包括 deployment 的 pod 还包括其他的: StatefulSet、DaemonSet...

func (*Project) ProtoTransform

func (project *Project) ProtoTransform() *types.ProjectModel

func (*Project) SetPodSelectors

func (project *Project) SetPodSelectors(selectors []string)

type SortStatePod

type SortStatePod []StatePod

func (SortStatePod) Len

func (s SortStatePod) Len() int

func (SortStatePod) Less

func (s SortStatePod) Less(i, j int) bool

func (SortStatePod) Swap

func (s SortStatePod) Swap(i, j int)

type StatePod

type StatePod struct {
	IsOld       bool
	Terminating bool
	Pending     bool
	OrderIndex  int
	Pod         *corev1.Pod
}

Jump to

Keyboard shortcuts

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