Documentation ¶
Index ¶
- Constants
- Variables
- func BuildJobsDtoFromInterface(input interface{}, prefixURL *url.URL) (*[]BuildJobDto, error)
- type ArtifactDto
- type ArtifactModel
- type Artifactory
- func (artifactory *Artifactory) Build(ctx context.Context, build *BuildJobModel, recorder *buildlogs.Recorder, ...) (*BuildJobModel, error)
- func (artifactory *Artifactory) CreateBuildJob(requesterIP string, request *BuildRequest) (*BuildJobDto, error)
- func (artifactory *Artifactory) DeleteJob(id string) error
- func (artifactory *Artifactory) GetBuild(request *BuildRequest) (*BuildJobDto, error)
- func (artifactory *Artifactory) ListJobs(query *JobQuery) (*database.Pagination, error)
- func (artifactory *Artifactory) ReservePendingBuild() (*BuildJobModel, error)
- func (artifactory *Artifactory) RunGarbageCollector()
- func (artifactory *Artifactory) RunMetrics(queued, building, failed *prometheus.GaugeVec)
- type AuditLogDto
- type AuditLogModel
- type BuildErrorType
- type BuildJobDto
- type BuildJobModel
- type BuildJobsDBRepository
- func (repository *BuildJobsDBRepository) Create(model BuildJobModel) (*BuildJobModel, error)
- func (repository *BuildJobsDBRepository) Delete(id uuid.UUID) error
- func (repository *BuildJobsDBRepository) FindByID(id uuid.UUID) (*BuildJobModel, error)
- func (repository *BuildJobsDBRepository) Get(request *BuildRequest) (*BuildJobModel, error)
- func (repository *BuildJobsDBRepository) List(query *JobQuery) (*database.Pagination, error)
- func (repository *BuildJobsDBRepository) ReservePendingBuild() (*BuildJobModel, error)
- func (repository *BuildJobsDBRepository) Save(model *BuildJobModel) error
- func (repository *BuildJobsDBRepository) TimeoutBuilds(timeout time.Duration) error
- func (repository *BuildJobsDBRepository) UpdateMetrics(queued, building, failed *prometheus.GaugeVec)
- type BuildJobsRepository
- type BuildRequest
- type BuildRequestError
- type BuildStatus
- type JobQuery
- type OptionFlag
Constants ¶
View Source
const ( MaxBuildAttempts = 5 MaxBuildDuration = time.Minute * 15 )
Variables ¶
View Source
var ( ErrNoArtifactStorage = errors.New("missing artifact storage") ErrBuildNotFound = errors.New("build not found") )
View Source
var ( ErrReleaseNotSupported = errors.New("release not supported") ErrTargetNotSupported = errors.New("target not supported") ErrOptionFlagNotSupported = errors.New("option flag not supported") )
View Source
var (
ErrTypeError = errors.New("wrong type returned")
)
Functions ¶
func BuildJobsDtoFromInterface ¶ added in v0.0.6
func BuildJobsDtoFromInterface(input interface{}, prefixURL *url.URL) (*[]BuildJobDto, error)
Types ¶
type ArtifactDto ¶
type ArtifactDto struct { ID string `json:"id"` Slug string `json:"slug"` DownloadURL string `json:"download_url"` Size int64 `json:"size"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
func ArtifactDtoFromModel ¶
func ArtifactDtoFromModel(model *ArtifactModel, downloadURL string) ArtifactDto
type ArtifactModel ¶
type ArtifactModel struct { ID uuid.UUID `gorm:"type:uuid;primary_key;"` Slug string BuildJobID string BuildJob BuildJobModel `gorm:"foreignKey:BuildJobID"` Filename string Size int64 CreatedAt time.Time UpdatedAt time.Time }
func (*ArtifactModel) BeforeCreate ¶
func (base *ArtifactModel) BeforeCreate(db *gorm.DB) error
func (ArtifactModel) TableName ¶
func (ArtifactModel) TableName() string
type Artifactory ¶
type Artifactory struct { BuildJobsRepository BuildJobsRepository ArtifactStorage storage.Handler SourceRepository string BuildContainerImage string PrefixURL *url.URL }
func New ¶
func New( buildJobsRepository BuildJobsRepository, artifactStorage storage.Handler, buildContainerImage string, sourceRepository string, prefixURL *url.URL, ) *Artifactory
func NewFromConfig ¶ added in v0.0.5
func NewFromConfig(ctx context.Context, c *config.CloudbuildOpts) (*Artifactory, error)
func (*Artifactory) Build ¶
func (artifactory *Artifactory) Build( ctx context.Context, build *BuildJobModel, recorder *buildlogs.Recorder, sources source.Downloader, builder firmware.Builder, ) (*BuildJobModel, error)
func (*Artifactory) CreateBuildJob ¶
func (artifactory *Artifactory) CreateBuildJob( requesterIP string, request *BuildRequest, ) (*BuildJobDto, error)
func (*Artifactory) DeleteJob ¶ added in v0.0.9
func (artifactory *Artifactory) DeleteJob(id string) error
func (*Artifactory) GetBuild ¶
func (artifactory *Artifactory) GetBuild(request *BuildRequest) (*BuildJobDto, error)
func (*Artifactory) ListJobs ¶ added in v0.0.5
func (artifactory *Artifactory) ListJobs(query *JobQuery) (*database.Pagination, error)
func (*Artifactory) ReservePendingBuild ¶ added in v0.0.5
func (artifactory *Artifactory) ReservePendingBuild() (*BuildJobModel, error)
func (*Artifactory) RunGarbageCollector ¶ added in v0.0.6
func (artifactory *Artifactory) RunGarbageCollector()
func (*Artifactory) RunMetrics ¶ added in v0.0.10
func (artifactory *Artifactory) RunMetrics(queued, building, failed *prometheus.GaugeVec)
type AuditLogDto ¶
type AuditLogDto struct { ID string `json:"id"` From BuildStatus `json:"from"` To BuildStatus `json:"to"` StdOut string `json:"std_out"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
func AuditLogDtoFromModel ¶
func AuditLogDtoFromModel(model *AuditLogModel) AuditLogDto
type AuditLogModel ¶
type AuditLogModel struct { ID uuid.UUID `gorm:"type:uuid;primary_key;"` BuildJobID string BuildJob BuildJobModel `gorm:"foreignKey:BuildJobID"` RequestIP string From BuildStatus To BuildStatus StdOut string CreatedAt time.Time UpdatedAt time.Time }
func (*AuditLogModel) BeforeCreate ¶
func (base *AuditLogModel) BeforeCreate(db *gorm.DB) error
func (AuditLogModel) TableName ¶
func (AuditLogModel) TableName() string
type BuildErrorType ¶
type BuildErrorType string
type BuildJobDto ¶
type BuildJobDto struct { ID string `json:"id"` Status BuildStatus `json:"status"` BuildAttempts int64 `json:"build_attempts"` CommitHash string `json:"commit_hash"` CommitRef string `json:"release"` Target string `json:"target"` Flags []OptionFlag `json:"flags"` BuildFlags []firmware.BuildFlag `json:"build_flags"` Artifacts []ArtifactDto `json:"artifacts,omitempty"` AuditLogs []AuditLogDto `json:"build_logs,omitempty"` ContainerImage string `json:"container_image"` BuildFlagsHash string `json:"build_flags_hash"` BuildStartedAt time.Time `json:"build_started_at"` BuildEndedAt time.Time `json:"build_ended_at"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
func BuildJobDtoFromModel ¶
func BuildJobDtoFromModel(model *BuildJobModel, prefixURL *url.URL) (*BuildJobDto, error)
type BuildJobModel ¶
type BuildJobModel struct { ID uuid.UUID `gorm:"type:uuid;primary_key;"` Status BuildStatus `gorm:"index:build_job_status_idx"` BuildAttempts int64 CommitHash string `gorm:"index:commit_hash_idx"` CommitRef string `gorm:"index:commit_ref_idx"` Target string `gorm:"index:target_idx"` Flags datatypes.JSON BuildFlags datatypes.JSON ContainerImage string BuildFlagsHash string `gorm:"index:build_flags_hash_idx"` Artifacts []ArtifactModel `gorm:"foreignKey:BuildJobID;constraint:OnDelete:CASCADE"` AuditLogs []AuditLogModel `gorm:"foreignKey:BuildJobID;constraint:OnDelete:CASCADE"` BuildStartedAt time.Time BuildEndedAt time.Time CreatedAt time.Time UpdatedAt time.Time }
func (*BuildJobModel) BeforeCreate ¶
func (base *BuildJobModel) BeforeCreate(db *gorm.DB) error
func (BuildJobModel) TableName ¶
func (BuildJobModel) TableName() string
type BuildJobsDBRepository ¶
type BuildJobsDBRepository struct {
// contains filtered or unexported fields
}
func NewBuildJobsDBRepository ¶
func NewBuildJobsDBRepository(db *gorm.DB) *BuildJobsDBRepository
func NewBuildJobsDBRepositoryFromConfig ¶ added in v0.0.5
func NewBuildJobsDBRepositoryFromConfig(c *config.CloudbuildOpts) (*BuildJobsDBRepository, error)
func (*BuildJobsDBRepository) Create ¶
func (repository *BuildJobsDBRepository) Create(model BuildJobModel) (*BuildJobModel, error)
func (*BuildJobsDBRepository) Delete ¶ added in v0.0.9
func (repository *BuildJobsDBRepository) Delete(id uuid.UUID) error
func (*BuildJobsDBRepository) FindByID ¶
func (repository *BuildJobsDBRepository) FindByID(id uuid.UUID) (*BuildJobModel, error)
func (*BuildJobsDBRepository) Get ¶
func (repository *BuildJobsDBRepository) Get(request *BuildRequest) (*BuildJobModel, error)
func (*BuildJobsDBRepository) List ¶ added in v0.0.5
func (repository *BuildJobsDBRepository) List(query *JobQuery) (*database.Pagination, error)
func (*BuildJobsDBRepository) ReservePendingBuild ¶
func (repository *BuildJobsDBRepository) ReservePendingBuild() (*BuildJobModel, error)
func (*BuildJobsDBRepository) Save ¶
func (repository *BuildJobsDBRepository) Save(model *BuildJobModel) error
func (*BuildJobsDBRepository) TimeoutBuilds ¶
func (repository *BuildJobsDBRepository) TimeoutBuilds(timeout time.Duration) error
func (*BuildJobsDBRepository) UpdateMetrics ¶ added in v0.0.10
func (repository *BuildJobsDBRepository) UpdateMetrics( queued, building, failed *prometheus.GaugeVec, )
type BuildJobsRepository ¶
type BuildJobsRepository interface { Get(request *BuildRequest) (*BuildJobModel, error) List(query *JobQuery) (*database.Pagination, error) Delete(id uuid.UUID) error FindByID(ID uuid.UUID) (*BuildJobModel, error) Create(model BuildJobModel) (*BuildJobModel, error) Save(model *BuildJobModel) error ReservePendingBuild() (*BuildJobModel, error) TimeoutBuilds(timeout time.Duration) error UpdateMetrics(queued, building, failed *prometheus.GaugeVec) }
type BuildRequest ¶ added in v0.0.10
type BuildRequest struct { Release string `json:"release"` Target string `json:"target"` Flags []OptionFlag `json:"flags"` }
func (*BuildRequest) GetBuildFlags ¶ added in v0.0.10
func (req *BuildRequest) GetBuildFlags() (*[]firmware.BuildFlag, error)
func (*BuildRequest) HashTargetAndFlags ¶ added in v0.0.10
func (req *BuildRequest) HashTargetAndFlags() string
func (*BuildRequest) Validate ¶ added in v0.0.10
func (req *BuildRequest) Validate() error
type BuildRequestError ¶ added in v0.0.10
func (*BuildRequestError) Error ¶ added in v0.0.10
func (e *BuildRequestError) Error() string
type BuildStatus ¶
type BuildStatus string
const ( VoidStatus BuildStatus = "VOID" WaitingForBuild BuildStatus = "WAITING_FOR_BUILD" BuildInProgress BuildStatus = "BUILD_IN_PROGRESS" BuildSuccess BuildStatus = "BUILD_SUCCESS" BuildError BuildStatus = "BUILD_ERROR" )
type JobQuery ¶ added in v0.0.6
type JobQuery struct { database.Pagination Status string `form:"status"` Release string `form:"release"` Target string `form:"target"` }
type OptionFlag ¶ added in v0.0.10
func (*OptionFlag) String ¶ added in v0.0.10
func (opt *OptionFlag) String() string
Click to show internal directories.
Click to hide internal directories.