Documentation
¶
Index ¶
- Constants
- func GetFromRaw[T any](tx *gorm.DB, field string) (T, bool)
- func IsForce(tx *gorm.DB) bool
- type Build
- type BuildInput
- type BuildLog
- type BuildShort
- type BuildStatus
- type BuildStep
- type BuildStepShort
- type Pipeline
- type PipelineConfig
- type PipelineConfigStep
- type PipelineInput
- type PipelineShort
- type Project
- type ProjectInput
- type ProjectShort
- type Secret
- type SecretInput
- type User
- type UserInput
- type Variable
- type VariableInput
- type Worker
- func (m *Worker) AfterCreate(tx *gorm.DB) error
- func (m *Worker) AfterDelete(tx *gorm.DB) error
- func (m *Worker) AfterSave(tx *gorm.DB) error
- func (m *Worker) AfterUpdate(tx *gorm.DB) error
- func (m *Worker) BeforeCreate(tx *gorm.DB) error
- func (m *Worker) BeforeDelete(tx *gorm.DB) error
- func (m *Worker) BeforeUpdate(tx *gorm.DB) error
- type WorkerInput
- type WorkerShort
- type WorkerStatus
- type WorkerStrategy
- type WorkerType
Constants ¶
View Source
const ( WorkerUseMin = iota WorkerBalanced WorkerUseMax )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Build ¶
type Build struct { ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` Number uint `json:"number" gorm:"index:,unique,composite:idx_builds;autoIncrement"` RevList pq.StringArray `json:"rev_list" gorm:"type:text[];not null;default:'{}'"` Status BuildStatus `json:"status" gorm:"not null;default:0"` Steps []BuildStep `json:"steps" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` PipelineID uuid.UUID `json:"pipeline_id" gorm:"type:uuid;index:,unique,composite:idx_builds"` WorkerID *uuid.UUID `json:"worker_id" gorm:"type:uuid"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` }
type BuildInput ¶
type BuildInput struct {
PipelineID string `json:"pipeline_id"`
}
type BuildLog ¶
type BuildLog struct { Command string `json:"command" gorm:"primaryKey"` // TODO: error: command can be bigger than limit for pk Idx int `json:"idx,omitempty"` Total int `json:"total,omitempty"` Output string `json:"output" gorm:"not null"` BuildStepID uuid.UUID `json:"build_step_id" gorm:"type:uuid;primaryKey"` }
type BuildShort ¶
type BuildShort struct { ID uuid.UUID `json:"id"` Number uint `json:"number"` RevList pq.StringArray `json:"rev_list" gorm:"type:text[]"` Status BuildStatus `json:"status"` Steps []BuildStepShort `json:"steps"` PipelineID uuid.UUID `json:"pipeline_id"` WorkerID uuid.NullUUID `json:"worker_id,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
type BuildStatus ¶
type BuildStatus uint8
const ( BuildScheduled BuildStatus = iota BuildRunning BuildSuccessful BuildFailed BuildCanceled )
func (BuildStatus) String ¶
func (s BuildStatus) String() string
type BuildStep ¶
type BuildStep struct { ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` Number int `json:"number" gorm:"not null"` Name string `json:"name" gorm:"uniqueIndex:idx_build_steps;not null"` Duration time.Duration `json:"duration" gorm:"not null"` Logs []BuildLog `json:"logs" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` BuildID uuid.UUID `json:"build_id" gorm:"type:uuid;uniqueIndex:idx_build_steps;not null"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` }
type BuildStepShort ¶
type Pipeline ¶
type Pipeline struct { ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` Name string `json:"name" gorm:"uniqueIndex:idx_pipelines;not null"` Branch string `json:"branch" gorm:"not null"` LastRev string `json:"last_rev" gorm:"not null"` Config PipelineConfig `json:"config" gorm:"not null;serializer:json"` Variables []Variable `json:"variables" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` Secrets []Secret `json:"secrets" gorm:"not null"` Builds []Build `json:"builds" gorm:"not null"` ProjectID uuid.UUID `json:"project_id" gorm:"type:uuid;uniqueIndex:idx_pipelines;not null"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` }
TODO: replace cascade constraint with trigger (issue: https://github.com/go-gorm/gorm/issues/5001)
type PipelineConfig ¶
type PipelineConfig struct { System string `json:"system"` Image string `json:"image"` Steps []PipelineConfigStep `json:"steps"` Cleanup []string `json:"cleanup"` }
type PipelineConfigStep ¶
type PipelineInput ¶
type PipelineInput struct { Name string `json:"name"` Branch string `json:"branch"` Config PipelineConfig `json:"config"` ProjectID uuid.UUID `json:"project_id"` }
type PipelineShort ¶
type Project ¶
type Project struct { ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` Name string `json:"name" gorm:"uniqueIndex:idx_projects"` Repo string `json:"repo" gorm:"not null"` Variables []Variable `json:"variables" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` Secrets []Secret `json:"secrets" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` Pipelines []Pipeline `json:"pipelines" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;not null"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` }
TODO: replace cascade constraint with trigger (issue: https://github.com/go-gorm/gorm/issues/5001)
type ProjectInput ¶
type ProjectShort ¶
type Secret ¶
type Secret struct { ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` Key string `json:"key" gorm:"not null"` Path string `json:"path,omitempty"` ProjectID *uuid.UUID `json:"project_id" gorm:"type:uuid"` PipelineID *uuid.UUID `json:"pipeline_id" gorm:"type:uuid"` Unique string `` /* 192-byte string literal not displayed */ CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` }
type SecretInput ¶
type User ¶
type User struct { ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` Username string `json:"username" gorm:"uniqueIndex:idx_users"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` }
TODO: rbac
type Variable ¶
type Variable struct { ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` Key string `json:"key" gorm:"not null"` Value string `json:"value" gorm:"not null"` Path string `json:"path,omitempty"` ProjectID *uuid.UUID `json:"project_id" gorm:"type:uuid"` PipelineID *uuid.UUID `json:"pipeline_id" gorm:"type:uuid"` Unique string `` /* 194-byte string literal not displayed */ CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` }
type VariableInput ¶
type Worker ¶
type Worker struct { ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` Name string `json:"name" gorm:"uniqueIndex:idx_workers;not null"` Address string `json:"address" gorm:"not null"` System string `json:"system" gorm:"not null"` Username string `json:"username" gorm:"not null"` Type WorkerType `json:"type" gorm:"not null"` Status WorkerStatus `json:"status" gorm:"not null;default:0"` Strategy WorkerStrategy `json:"strategy" gorm:"not null;default:0"` ActiveBuilds int `json:"active_builds" gorm:"not null;default:0"` Capacity int `json:"capacity" gorm:"not null;default:0"` Builds []Build `json:"builds" gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;not null"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` }
type WorkerInput ¶
type WorkerShort ¶
type WorkerShort struct { ID uuid.UUID `json:"id"` Name string `json:"name"` Address string `json:"address"` System string `json:"system"` Username string `json:"username"` Type WorkerType `json:"type"` Status WorkerStatus `json:"status"` Strategy WorkerStrategy `json:"strategy"` ActiveBuilds int `json:"active_builds"` Capacity int `json:"capacity"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
type WorkerStatus ¶
type WorkerStatus int
const ( WorkerIdle WorkerStatus = iota WorkerUsed WorkerUnreachable )
type WorkerStrategy ¶
type WorkerStrategy int
Click to show internal directories.
Click to hide internal directories.