models

package
v0.0.0-...-3b85bd6 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BeforeClone   = "before_clone"
	AfterClone    = "after_clone"
	BeforePrepare = "before_prepare"
	AfterPrepare  = "after_prepare"
	BeforeRelease = "before_release"
	AfterRelease  = "after_release"

	Init    = "init"    // 创建目录
	Clone   = "clone"   // 克隆代码
	Prepare = "prepare" // 准备配置文件、共享文件等
	Release = "release" // 切换版本

	StatusWaiting  = "waiting"
	StatusRunning  = "running"
	StatusFailed   = "failed"
	StatusFinished = "finished"
)
View Source
const (
	UserRoleAdmin = "admin"
	UserRoleUser  = "user"
)
View Source
const (
	InviteStatusWaiting  = "inviting"
	InviteStatusJoined   = "joined"
	InviteStatusRejected = "rejected"
)

Variables

View Source
var CabinetClass = class.Make[Cabinet]()
View Source
var CommandClass = class.Make[Command]()
View Source
var ConfigFileClass = class.Make[ConfigFile]()
View Source
var DeploymentClass = class.Make[Deployment]()
View Source
var GroupClass = class.Make[Group]()
View Source
var KeyClass = class.Make[Key]()
View Source
var ProjectClass = class.Make[Project]()
View Source
var ProjectEnvironmentClass = class.Make[ProjectEnvironment]()
View Source
var ShareFileClass = class.Make[ShareFile]()
View Source
var UserClass = class.Make[User]()
View Source
var UserGroupClass = class.Make[UserGroup]()
View Source
var UserProjectClass = class.Make[UserProject]()

Functions

func Cabinets

func Cabinets() *table.Table[Cabinet]

func Commands

func Commands() *table.Table[Command]

func ConfigFiles

func ConfigFiles() *table.Table[ConfigFile]

func Deployments

func Deployments() *table.Table[Deployment]

func Groups

func Groups() *table.Table[Group]

func Keys

func Keys() *table.Table[Key]

func ProjectEnvironments

func ProjectEnvironments() *table.Table[ProjectEnvironment]

func Projects

func Projects() *table.Table[Project]

func ShareFiles

func ShareFiles() *table.Table[ShareFile]

func UserGroups

func UserGroups() *table.Table[UserGroup]

func UserProjects

func UserProjects() *table.Table[UserProject]

func Users

func Users() *table.Table[User]

Types

type Cabinet

type Cabinet struct {
	table.Model[Cabinet] `json:"-"`

	Id        string   `json:"id"`
	CreatorId int      `json:"creator_id"`
	Name      string   `json:"name"`     // 名称
	Settings  []Server `json:"settings"` // 配置
	CreatedAt string   `json:"created_at"`
	UpdatedAt string   `json:"updated_at"`
}

type Callback

type Callback struct {
	Name    string   `json:"name"`
	Webhook string   `json:"webhook"`
	Events  []string `json:"events"`
	Enabled bool     `json:"enabled"`
}

type Command

type Command struct {
	table.Model[Command] `json:"-"`

	Id              int    `json:"id"`
	Name            string `json:"name"`             // 名称
	ProjectId       int    `json:"project_id"`       // 项目ID
	Step            string `json:"step"`             // 步骤
	Sort            int    `json:"sort"`             // 排序
	User            string `json:"user"`             // 运行用户
	Script          string `json:"script"`           // shell 脚本
	Environments    []int  `json:"environments"`     // 环境
	Optional        bool   `json:"optional"`         // 是否可选
	DefaultSelected bool   `json:"default_selected"` // 是否默认选中
	CreatedAt       string `json:"created_at"`
	UpdatedAt       string `json:"updated_at"`
}

type CommandOutput

type CommandOutput struct {
	Server
	Outputs string `json:"outputs,omitempty"`
	Status  string `json:"status"`
	Time    int    `json:"time,omitempty"`
}

type CommandResult

type CommandResult struct {
	Step          string                   `json:"step"`
	Servers       map[string]CommandOutput `json:"servers"` // { ip : CommandOutput}
	Command       int                      `json:"command,omitempty"`
	Name          string                   `json:"name,omitempty"`
	TimeConsuming int                      `json:"time_consuming,omitempty"` // 用时,单位秒
}

type ConfigFile

type ConfigFile struct {
	table.Model[ConfigFile] `json:"-"`

	Id           string `json:"id"`
	ProjectId    int    `json:"project_id"`   // 项目ID
	Name         string `json:"name"`         // 名称
	Path         string `json:"path"`         // 文件路径
	Content      string `json:"content"`      // 内容
	Environments []int  `json:"environments"` // 关联环境
	CreatedAt    string `json:"created_at"`
	UpdatedAt    string `json:"updated_at"`
}

type Deployment

type Deployment struct {
	table.Model[Deployment] `json:"-"`

	Id           string          `json:"id"`
	ProjectId    int             `json:"project_id"` // 项目ID
	Version      string          `json:"version"`    // 部署版本
	Comment      string          `json:"comment"`    // 说明
	Commit       string          `json:"commit"`     // 提交 hash
	Status       string          `json:"status"`     // 状态
	Params       map[string]bool `json:"params"`     // {step: bool}
	Results      []CommandResult `json:"results"`
	Environments []int           `json:"environments"`
	CreatedAt    string          `json:"created_at"`
	UpdatedAt    string          `json:"updated_at"`
}

type EnvironmentSettings

type EnvironmentSettings struct {
	Servers         []Server `json:"servers"`          // 服务器列表
	Cabinets        []string `json:"cabinets"`         // 服务器租
	DefaultSelected bool     `json:"default_selected"` // 默认选中
	LinkageDeploy   string   `json:"linkage_deploy"`   // 联动部署环境
}

type Group

type Group struct {
	table.Model[Group] `json:"-"`

	Id        int    `json:"id"`
	Name      string `json:"name"`    // 名称
	CreatorId int    `json:"creator"` // 创建者
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type Key

type Key struct {
	table.Model[Key] `json:"-"`

	Id         int    `json:"id"`
	Name       string `json:"name"`        // 名称
	PublicKey  string `json:"public_key"`  // 公钥
	PrivateKey string `json:"private_key"` // 私钥
	CreatedAt  string `json:"created_at"`
	UpdatedAt  string `json:"updated_at"`
}

type Project

type Project struct {
	table.Model[Project] `json:"-"`

	Id            int             `json:"id"`
	Uuid          string          `json:"uuid"`
	Settings      ProjectSettings `json:"settings"`
	Name          string          `json:"name"`
	CreatorId     int             `json:"creator_id"`
	GroupId       int             `json:"group_id"`
	KeyId         int             `json:"key_id"`
	RepoAddress   string          `json:"repo_address"`
	ProjectPath   string          `json:"project_path"`
	DefaultBranch string          `json:"default_branch"`
	CreatedAt     string          `json:"created_at"`
	UpdatedAt     string          `json:"updated_at"`
}

type ProjectDetail

type ProjectDetail struct {
	*Project
	Key     *Key                `json:"key"`
	Group   *Group              `json:"group"`
	Members []*contracts.Fields `json:"members"`
}

type ProjectEnvVar

type ProjectEnvVar struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type ProjectEnvironment

type ProjectEnvironment struct {
	table.Model[ProjectEnvironment] `json:"-"`

	Id        int                 `json:"id"`
	ProjectId int                 `json:"project_id"`
	Name      string              `json:"name"`
	Settings  EnvironmentSettings `json:"settings"`
	CreatedAt string              `json:"created_at"`
	UpdatedAt string              `json:"updated_at"`
}

type ProjectSettings

type ProjectSettings struct {
	EnvVars   []ProjectEnvVar `json:"vars"`
	Branches  []string        `json:"branches"`
	Tags      []string        `json:"tags"`
	Callbacks []Callback      `json:"callbacks"`
}

type Server

type Server struct {
	Host        string `json:"host"`
	Port        int    `json:"port"`
	User        string `json:"user"`
	Disabled    bool   `json:"disabled,omitempty"`
	Name        string `json:"name,omitempty"`
	Environment int    `json:"environment"`
}

type ShareFile

type ShareFile struct {
	table.Model[ShareFile] `json:"-"`

	Id        string `json:"id"`
	ProjectId int    `json:"project_id"` // 项目ID
	Name      string `json:"name"`       // 名称
	Path      string `json:"path"`       // 文件路径
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type User

type User struct {
	table.Model[User] `json:"-"`

	Id        string `json:"id"`
	Username  string `json:"username"`
	Nickname  string `json:"nickname"`
	Avatar    string `json:"avatar"`
	Role      string `json:"role"`
	Password  string `json:"password,omitempty"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

func (User) GetId

func (u User) GetId() string

GetId 实现 auth 需要的方法

type UserGroup

type UserGroup struct {
	table.Model[UserGroup] `json:"-"`

	Id        string `json:"id"`
	GroupId   int    `json:"group_id"` // 项目ID
	UserId    int    `json:"user_id"`  // 用户ID
	Status    string `json:"status"`   // 状态:inviting、joined、rejected
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type UserProject

type UserProject struct {
	table.Model[UserProject] `json:"-"`

	Id        string `json:"id"`
	ProjectId int    `json:"project_id"` // 项目ID
	UserId    int    `json:"user_id"`    // 用户ID
	Status    string `json:"status"`     // 状态:inviting、joined、rejected
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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