Documentation
¶
Overview ¶
Concurrency invariant: read-modify-write transactions in this package take a row lock via SELECT ... FOR UPDATE (clause.Locking{Strength: "UPDATE"}) to serialize concurrent updates of the same row and prevent lost updates. On a single-writer backend (SQLite) the lock is effectively a no-op, but it is load-bearing on any backend that permits concurrent writers — do not remove it.
Index ¶
- func NewSQLStore(ctx context.Context, cfg config.Database) (common.Store, error)
- type Address
- type Base
- type ControllerInfo
- type CredentialsGetter
- type Enterprise
- type EnterpriseEvent
- type FileBlob
- type FileObject
- type FileObjectTag
- type ForgeEntity
- type ForgeInstance
- type ForgeInstanceEvent
- type GiteaCredentials
- type GithubCredentials
- type GithubEndpoint
- type Instance
- type InstanceStatusUpdate
- type Organization
- type OrganizationEvent
- type Pool
- type Proxy
- type Repository
- type RepositoryEvent
- type ScaleSet
- type ScaleSetJob
- type Tag
- type Template
- type User
- type WorkflowJob
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Base ¶
type ControllerInfo ¶
type ControllerInfo struct {
Base
ControllerID uuid.UUID
// CallbackURL is the URL where userdata scripts call back into, to send status updates
// and installation progress.
CallbackURL string
// MetadataURL is the base URL from which runners can get their installation metadata.
MetadataURL string
// WebhookBaseURL is the base URL used to construct the controller webhook URL.
WebhookBaseURL string
// AgentURL is the websocket enabled URL where garm agents connect to.
AgentURL string
// GARMAgentReleasesURL is the URL from which GARM can sync garm-agent binaries. Alternatively
// the user can manually upload binaries.
GARMAgentReleasesURL string
// SyncGARMAgentTools enables or disables automatic sync of garm-agent tools.
SyncGARMAgentTools bool
// GARMAgentVersion is the preferred GARM agent version. Empty or "latest" will
// default to the latest version available at GARMAgentReleasesURL. A specific version
// will cache and download (if SyncGARMAgentTools is true) the specified version.
GARMAgentVersion string
// MinimumJobAgeBackoff is the minimum time that a job must be in the queue
// before GARM will attempt to allocate a runner to service it. This backoff
// is useful if you have idle runners in various pools that could potentially
// pick up the job. GARM would allow this amount of time for runners to react
// before spinning up a new one and potentially having to scale down later.
MinimumJobAgeBackoff uint
// CachedGARMAgentReleases stores the release index fetched from
// GARMAgentReleasesURL: the source URL plus the list of releases
// (a marshaled util.AgentReleaseIndex).
CachedGARMAgentReleases datatypes.JSON
// CachedGARMAgentReleaseFetchedAt is the timestamp when the release index was last fetched
CachedGARMAgentReleaseFetchedAt *time.Time
// AllowInsecureGARMAgent tells GARM to configure the garm-agent (when used) to connect
// to the GARM API even when not using TLS.
AllowInsecureGARMAgent bool
// CACertBundle holds a certificate bundle meant to validate the certificate
// used by GARM itself. This can be just the root certificate that can validate
// the GARM TLS certificate, a chain or multiple root CAs.
CACertBundle []byte
}
type CredentialsGetter ¶ added in v0.2.0
type Enterprise ¶
type Enterprise struct {
Base
CredentialsID *uint `gorm:"index"`
Credentials GithubCredentials `gorm:"foreignKey:CredentialsID;constraint:OnDelete:SET NULL"`
PoolManagerRunning bool
PoolManagerFailureReason string
Name string `gorm:"index:idx_ent_name_nocase,expression:LOWER(name)"`
WebhookSecret []byte
Pools []Pool `gorm:"foreignKey:EnterpriseID"`
ScaleSet []ScaleSet `gorm:"foreignKey:EnterpriseID"`
Jobs []WorkflowJob `gorm:"foreignKey:EnterpriseID;constraint:OnDelete:SET NULL"`
PoolBalancerType params.PoolBalancerType `gorm:"type:varchar(64)"`
AgentMode bool `gorm:"index:enterprise_agent_idx"`
EndpointName *string `gorm:"index:idx_ent_name_nocase,expression:LOWER(endpoint_name)"`
Endpoint GithubEndpoint `gorm:"foreignKey:EndpointName;constraint:OnDelete:SET NULL"`
Events []EnterpriseEvent `gorm:"foreignKey:EnterpriseID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
}
func (*Enterprise) GetEndpoint ¶ added in v0.2.0
func (e *Enterprise) GetEndpoint() GithubEndpoint
Enterprise implements ForgeEntity
func (*Enterprise) GetEndpointName ¶ added in v0.2.0
func (e *Enterprise) GetEndpointName() *string
type EnterpriseEvent ¶ added in v0.2.0
type EnterpriseEvent struct {
gorm.Model
EventType params.EventType
EventLevel params.EventLevel
Message string `gorm:"type:text"`
EnterpriseID uuid.UUID `gorm:"index:idx_enterprise_event"`
Enterprise Enterprise `gorm:"foreignKey:EnterpriseID"`
}
type FileBlob ¶ added in v0.2.0
type FileBlob struct {
gorm.Model
FileObjectID uint `gorm:"index:idx_fileobject_blob_id"`
Content []byte // SQLite only; NULL for PostgreSQL
LOOID uint32 `gorm:"column:lo_oid;default:0"` // PostgreSQL Large Object OID; 0 for SQLite
}
FileBlob is the immutable blob of bytes that once written will not be changed. We leave the SHA256, file type and size in the parent table, because we need to we able to get that info easily, without preloading the blob table.
type FileObject ¶ added in v0.2.0
type FileObject struct {
gorm.Model
// Name is the name of the file
Name string `gorm:"type:text;index:idx_fo_name"`
// Description is a description for the file
Description string `gorm:"type:text"`
// FileType holds the MIME type or file type description
FileType string `gorm:"type:text"`
// Size is the file size in bytes
Size int64 `gorm:"type:integer"`
// SHA256 is the sha256 checksum (hex encoded)
SHA256 string `gorm:"type:text;index:idx_fo_chksum"`
// Tags is a JSON array of tags
TagsList []FileObjectTag `gorm:"foreignKey:FileObjectID;constraint:OnDelete:CASCADE"`
// Content is a foreign key to a different table where the blob is actually stored.
// Updating a field in an sqlite 3 DB will read the entire field, update the column
// and write it back to a different location. SQLite3 will then mark the old row as "deleted"
// and allow it to be vaccumed. But if we have a blob column with a huge blob, any
// update operation will consume a lot of resources and take a long time.
// Using a dedicated table for the blob (which doesn't change), speeds up updates of
// metadata fields like name, description, tags, etc.
Content FileBlob `gorm:"foreignKey:FileObjectID;constraint:OnDelete:CASCADE"`
}
FileObject represents the table that holds files. This can be used to store GARM agent binaries, runner binary downloads that may be cached, etc.
type FileObjectTag ¶ added in v0.2.0
type FileObjectTag struct {
ID uint `gorm:"primaryKey"`
FileObjectID uint `gorm:"index:idx_fileobject_tags_doc_id,priority:1;index:idx_fileobject_tags_tag,priority:1;not null"`
Tag string `gorm:"index:idx_fileobject_tags_tag,priority:2,expression:LOWER(tag);not null"`
}
FileObjectTag represents the many-to-many relationship between documents and tags
type ForgeEntity ¶ added in v0.2.0
type ForgeEntity interface {
GetEndpoint() GithubEndpoint
GetEndpointName() *string
}
ForgeEntity represents an entity (Repository, Organization, Enterprise) that can have forge credentials
type ForgeInstance ¶ added in v0.2.2
type ForgeInstance struct {
Base
GiteaCredentialsID *uint `gorm:"index"`
GiteaCredentials GiteaCredentials `gorm:"foreignKey:GiteaCredentialsID;constraint:OnDelete:SET NULL"`
PoolManagerRunning bool
PoolManagerFailureReason string
WebhookSecret []byte
Pools []Pool `gorm:"foreignKey:ForgeInstanceID"`
Jobs []WorkflowJob `gorm:"foreignKey:ForgeInstanceID;constraint:OnDelete:SET NULL"`
PoolBalancerType params.PoolBalancerType `gorm:"type:varchar(64)"`
AgentMode bool `gorm:"index:forgeinstance_agent_idx"`
EndpointName *string `gorm:"uniqueIndex:idx_forgeinstance_endpoint_nocase,expression:LOWER(endpoint_name)"`
Endpoint GithubEndpoint `gorm:"foreignKey:EndpointName;constraint:OnDelete:SET NULL"`
Events []ForgeInstanceEvent `gorm:"foreignKey:ForgeInstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
}
func (*ForgeInstance) GetEndpoint ¶ added in v0.2.2
func (f *ForgeInstance) GetEndpoint() GithubEndpoint
ForgeInstance implements ForgeEntity
func (*ForgeInstance) GetEndpointName ¶ added in v0.2.2
func (f *ForgeInstance) GetEndpointName() *string
type ForgeInstanceEvent ¶ added in v0.2.2
type ForgeInstanceEvent struct {
gorm.Model
EventType params.EventType
EventLevel params.EventLevel
Message string `gorm:"type:text"`
ForgeInstanceID uuid.UUID `gorm:"index:idx_forgeinstance_event"`
ForgeInstance ForgeInstance `gorm:"foreignKey:ForgeInstanceID"`
}
type GiteaCredentials ¶ added in v0.2.0
type GiteaCredentials struct {
gorm.Model
Name string `gorm:"index:idx_gitea_credentials,unique,expression:LOWER(name);type:varchar(64)"`
UserID *uuid.UUID `gorm:"index:idx_gitea_credentials,unique"`
User User `gorm:"foreignKey:UserID"`
Description string `gorm:"type:text"`
AuthType params.ForgeAuthType `gorm:"index"`
Payload []byte
Endpoint GithubEndpoint `gorm:"foreignKey:EndpointName"`
EndpointName *string `gorm:"index"`
Repositories []Repository `gorm:"foreignKey:GiteaCredentialsID"`
Organizations []Organization `gorm:"foreignKey:GiteaCredentialsID"`
ForgeInstances []ForgeInstance `gorm:"foreignKey:GiteaCredentialsID"`
}
func (GiteaCredentials) GetEndpointName ¶ added in v0.2.0
func (g GiteaCredentials) GetEndpointName() *string
func (GiteaCredentials) GetID ¶ added in v0.2.0
func (g GiteaCredentials) GetID() uint
type GithubCredentials ¶ added in v0.1.5
type GithubCredentials struct {
gorm.Model
Name string `gorm:"index:idx_github_credentials,unique,expression:LOWER(name);type:varchar(64)"`
UserID *uuid.UUID `gorm:"index:idx_github_credentials,unique"`
User User `gorm:"foreignKey:UserID"`
Description string `gorm:"type:text"`
AuthType params.ForgeAuthType `gorm:"index"`
Payload []byte
Endpoint GithubEndpoint `gorm:"foreignKey:EndpointName"`
EndpointName *string `gorm:"index"`
// ReserveUsageEnabled toggles whether or not to allocate a certain
// percentage of the available rate limit to critical operations such
// as delete operations for runners that have finished their jobs.
ReserveUsageEnabled bool
ReserveUsagePercentage int
Repositories []Repository `gorm:"foreignKey:CredentialsID"`
Organizations []Organization `gorm:"foreignKey:CredentialsID"`
Enterprises []Enterprise `gorm:"foreignKey:CredentialsID"`
}
func (GithubCredentials) GetEndpointName ¶ added in v0.2.0
func (g GithubCredentials) GetEndpointName() *string
func (GithubCredentials) GetID ¶ added in v0.2.0
func (g GithubCredentials) GetID() uint
type GithubEndpoint ¶ added in v0.1.5
type GithubEndpoint struct {
Name string `gorm:"type:varchar(64);primary_key;uniqueIndex:idx_endpoint_name_nocase,expression:LOWER(name)"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
EndpointType params.EndpointType `gorm:"index:idx_endpoint_type"`
ToolsMetadataURL string `gorm:"type:text"`
UseInternalToolsMetadata bool
Description string `gorm:"type:text"`
APIBaseURL string `gorm:"type:text"`
UploadBaseURL string `gorm:"type:text"`
BaseURL string `gorm:"type:text"`
CACertBundle []byte
}
type Instance ¶
type Instance struct {
Base
ProviderID *string `gorm:"uniqueIndex"`
Name string `gorm:"uniqueIndex"`
AgentID int64
OSType commonParams.OSType
OSArch commonParams.OSArch
OSName string
OSVersion string
Addresses []Address `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
Status commonParams.InstanceStatus
RunnerStatus params.RunnerStatus
Heartbeat time.Time
CallbackURL string
MetadataURL string
ProviderFault []byte
CreateAttempt int
TokenFetched bool
JitConfiguration []byte
GitHubRunnerGroup string
AditionalLabels datatypes.JSON
Capabilities datatypes.JSON
// Generation is the pool generation at the time of creating this instance.
// This field is to track a divergence between when the instance was created
// and the settings currently set on a pool. We can then use this field to know
// if the instance is out of date with the pool, allowing us to remove it if we
// need to.
Generation uint64
PoolID *uuid.UUID
Pool Pool `gorm:"foreignKey:PoolID"`
ScaleSetFkID *uint
ScaleSet ScaleSet `gorm:"foreignKey:ScaleSetFkID"`
StatusMessages []InstanceStatusUpdate `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
Job *WorkflowJob `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
}
type InstanceStatusUpdate ¶
type Organization ¶
type Organization struct {
Base
CredentialsID *uint `gorm:"index"`
Credentials GithubCredentials `gorm:"foreignKey:CredentialsID;constraint:OnDelete:SET NULL"`
GiteaCredentialsID *uint `gorm:"index"`
GiteaCredentials GiteaCredentials `gorm:"foreignKey:GiteaCredentialsID;constraint:OnDelete:SET NULL"`
PoolManagerRunning bool
PoolManagerFailureReason string
Name string `gorm:"index:idx_org_name_nocase,expression:LOWER(name)"`
WebhookSecret []byte
Pools []Pool `gorm:"foreignKey:OrgID"`
ScaleSet []ScaleSet `gorm:"foreignKey:OrgID"`
Jobs []WorkflowJob `gorm:"foreignKey:OrgID;constraint:OnDelete:SET NULL"`
PoolBalancerType params.PoolBalancerType `gorm:"type:varchar(64)"`
AgentMode bool `gorm:"index:org_agent_idx"`
EndpointName *string `gorm:"index:idx_org_name_nocase,expression:LOWER(endpoint_name)"`
Endpoint GithubEndpoint `gorm:"foreignKey:EndpointName;constraint:OnDelete:SET NULL"`
Events []OrganizationEvent `gorm:"foreignKey:OrgID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
}
func (*Organization) GetEndpoint ¶ added in v0.2.0
func (o *Organization) GetEndpoint() GithubEndpoint
Organization implements ForgeEntity
func (*Organization) GetEndpointName ¶ added in v0.2.0
func (o *Organization) GetEndpointName() *string
type OrganizationEvent ¶ added in v0.2.0
type OrganizationEvent struct {
gorm.Model
EventType params.EventType
EventLevel params.EventLevel
Message string `gorm:"type:text"`
OrgID uuid.UUID `gorm:"index:idx_org_event"`
Org Organization `gorm:"foreignKey:OrgID"`
}
type Pool ¶
type Pool struct {
Base
ProviderName string `gorm:"index:idx_pool_type"`
RunnerPrefix string
MaxRunners uint
MinIdleRunners uint
RunnerBootstrapTimeout uint
Image string `gorm:"index:idx_pool_type"`
Flavor string `gorm:"index:idx_pool_type"`
OSType commonParams.OSType
OSArch commonParams.OSArch
Tags []*Tag `gorm:"many2many:pool_tags;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
Enabled bool
// ExtraSpecs is an opaque json that gets sent to the provider
// as part of the bootstrap params for instances. It can contain
// any kind of data needed by providers.
ExtraSpecs datatypes.JSON
GitHubRunnerGroup string
EnableShell bool
// Generation holds the numeric generation of the pool. This number
// will be incremented, every time certain settings of the pool, which
// may influence how runners are created (flavor, specs, image) are changed.
// When a runner is created, this generation will be copied to the runners as
// well. That way if some settings diverge, we can target those runners
// to be recreated.
Generation uint64
RepoID *uuid.UUID `gorm:"index"`
Repository Repository `gorm:"foreignKey:RepoID;"`
OrgID *uuid.UUID `gorm:"index"`
Organization Organization `gorm:"foreignKey:OrgID"`
EnterpriseID *uuid.UUID `gorm:"index"`
Enterprise Enterprise `gorm:"foreignKey:EnterpriseID"`
ForgeInstanceID *uuid.UUID `gorm:"index"`
ForgeInstance ForgeInstance `gorm:"foreignKey:ForgeInstanceID"`
TemplateID *uint `gorm:"index"`
Template Template `gorm:"foreignKey:TemplateID"`
ProxyID *uint `gorm:"index"`
Proxy Proxy `gorm:"foreignKey:ProxyID"`
Instances []Instance `gorm:"foreignKey:PoolID"`
Jobs []WorkflowJob `gorm:"foreignKey:PoolID;constraint:OnDelete:SET NULL"`
Priority uint `gorm:"index:idx_pool_priority"`
}
type Proxy ¶ added in v0.2.2
type Proxy struct {
gorm.Model
Name string `gorm:"index:idx_proxy_name,unique,expression:LOWER(name);type:varchar(64)"`
Description string `gorm:"type:text"`
HTTPProxy string `gorm:"column:http_proxy;type:text"`
HTTPSProxy string `gorm:"column:https_proxy;type:text"`
NoProxy string `gorm:"column:no_proxy;type:text"`
// Credentials holds the sealed proxy credentials (username/password),
// if any were set.
Credentials []byte
Pools []Pool `gorm:"foreignKey:ProxyID"`
ScaleSets []ScaleSet `gorm:"foreignKey:ProxyID"`
}
Proxy holds a named proxy definition. Pools and scale sets may reference a proxy, in which case runners created for them will be configured to use the proxy settings defined here.
type Repository ¶
type Repository struct {
Base
CredentialsID *uint `gorm:"index"`
Credentials GithubCredentials `gorm:"foreignKey:CredentialsID;constraint:OnDelete:SET NULL"`
GiteaCredentialsID *uint `gorm:"index"`
GiteaCredentials GiteaCredentials `gorm:"foreignKey:GiteaCredentialsID;constraint:OnDelete:SET NULL"`
PoolManagerRunning bool
PoolManagerFailureReason string
Owner string `gorm:"index:idx_owner_nocase,unique,expression:LOWER(owner)"`
Name string `gorm:"index:idx_owner_nocase,unique,expression:LOWER(name)"`
WebhookSecret []byte
Pools []Pool `gorm:"foreignKey:RepoID"`
ScaleSets []ScaleSet `gorm:"foreignKey:RepoID"`
Jobs []WorkflowJob `gorm:"foreignKey:RepoID;constraint:OnDelete:SET NULL"`
PoolBalancerType params.PoolBalancerType `gorm:"type:varchar(64)"`
AgentMode bool `gorm:"index:repo_agent_idx"`
EndpointName *string `gorm:"index:idx_owner_nocase,unique,expression:LOWER(endpoint_name)"`
Endpoint GithubEndpoint `gorm:"foreignKey:EndpointName;constraint:OnDelete:SET NULL"`
Events []RepositoryEvent `gorm:"foreignKey:RepoID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
}
func (*Repository) GetEndpoint ¶ added in v0.2.0
func (r *Repository) GetEndpoint() GithubEndpoint
Repository implements ForgeEntity
func (*Repository) GetEndpointName ¶ added in v0.2.0
func (r *Repository) GetEndpointName() *string
type RepositoryEvent ¶ added in v0.2.0
type RepositoryEvent struct {
gorm.Model
EventType params.EventType
EventLevel params.EventLevel
Message string `gorm:"type:text"`
RepoID uuid.UUID `gorm:"index:idx_repo_event"`
Repo Repository `gorm:"foreignKey:RepoID"`
}
type ScaleSet ¶ added in v0.2.0
type ScaleSet struct {
gorm.Model
// ScaleSetID is the github ID of the scale set. This field may not be set if
// the scale set was ceated in GARM but has not yet been created in GitHub.
// The scale set ID is also not globally unique. It is only unique within the context
// of an entity.
ScaleSetID int `gorm:"index:idx_scale_set"`
Name string `gorm:"unique_index:idx_name"`
GitHubRunnerGroup string `gorm:"unique_index:idx_name"`
DisableUpdate bool
// State stores the provisioning state of the scale set in GitHub
State params.ScaleSetState
// ExtendedState stores a more detailed message regarding the State.
// If an error occurs, the reason for the error will be stored here.
ExtendedState string
ProviderName string
RunnerPrefix string
MaxRunners uint
MinIdleRunners uint
RunnerBootstrapTimeout uint
Image string
Flavor string
OSType commonParams.OSType
OSArch commonParams.OSArch
Enabled bool
LastMessageID int64
DesiredRunnerCount int
// ExtraSpecs is an opaque json that gets sent to the provider
// as part of the bootstrap params for instances. It can contain
// any kind of data needed by providers.
ExtraSpecs datatypes.JSON
EnableShell bool
// Generation is the scaleset generation at the time of creating this instance.
// This field is to track a divergence between when the instance was created
// and the settings currently set on a scaleset. We can then use this field to know
// if the instance is out of date with the scaleset, allowing us to remove it if we
// need to.
Generation uint64
RepoID *uuid.UUID `gorm:"index"`
Repository Repository `gorm:"foreignKey:RepoID;"`
OrgID *uuid.UUID `gorm:"index"`
Organization Organization `gorm:"foreignKey:OrgID"`
EnterpriseID *uuid.UUID `gorm:"index"`
Enterprise Enterprise `gorm:"foreignKey:EnterpriseID"`
TemplateID *uint `gorm:"index"`
Template Template `gorm:"foreignKey:TemplateID"`
ProxyID *uint `gorm:"index"`
Proxy Proxy `gorm:"foreignKey:ProxyID"`
Tags []*Tag `gorm:"many2many:scaleset_tags;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
Instances []Instance `gorm:"foreignKey:ScaleSetFkID"`
// Jobs is the informational ledger of jobs GitHub routed to this
// scale set. It is removed together with the scale set.
Jobs []ScaleSetJob `gorm:"foreignKey:ScaleSetFkID;constraint:OnDelete:CASCADE"`
}
ScaleSet represents a github scale set. Scale sets are almost identical to pools with the notable difference that scheduling happens server side in github.
type ScaleSetJob ¶ added in v0.2.2
type ScaleSetJob struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time
UpdatedAt time.Time
// ScaleSetJobID is the job ID assigned by the GitHub actions service.
ScaleSetJobID string `gorm:"uniqueIndex"`
// ScaleSetFkID is NULL only for records migrated from workflow_jobs,
// which never recorded the owning scale set.
ScaleSetFkID *uint `gorm:"index"`
ScaleSet ScaleSet `gorm:"foreignKey:ScaleSetFkID"`
WorkflowRunID int64 `gorm:"index"`
RunnerRequestID int64
JobWorkflowRef string
Name string
Status string `gorm:"index"`
Result string
EventName string
RequestLabels datatypes.JSON
RepositoryName string
RepositoryOwner string
RunnerGroupName string
RunnerID int64
RunnerName string
WorkflowRunURL string
// Timestamps reported by GitHub for the job's routing funnel.
QueueTime time.Time
ScaleSetAssignTime time.Time
RunnerAssignTime time.Time
FinishTime time.Time
}
ScaleSetJob records a job GitHub routed to a scale set, as seen on the scale set's message queue. GitHub schedules these jobs server side. GARM records them so users can list them and see which runner serviced them. Nothing in GARM acts on these records.
type Template ¶ added in v0.2.0
type Template struct {
gorm.Model
Name string `gorm:"index:idx_template,unique;type:varchar(128)"`
UserID *uuid.UUID `gorm:"index:idx_template,unique"`
User User `gorm:"foreignKey:UserID"`
Description string `gorm:"type:text"`
OSType commonParams.OSType `gorm:"type:varchar(32);index:idx_tpl_os_type"`
ForgeType params.EndpointType `gorm:"type:varchar(32);index:idx_tpl_forge_type"`
Data []byte
ScaleSets []ScaleSet `gorm:"foreignKey:TemplateID"`
Pools []Pool `gorm:"foreignKey:TemplateID"`
}
type WorkflowJob ¶ added in v0.1.2
type WorkflowJob struct {
// ID is the ID of the job.
ID int64 `gorm:"index"`
// WorkflowJobID is the ID of the workflow job.
WorkflowJobID int64 `gorm:"index:workflow_job_id_idx"`
// RunID is the ID of the workflow run. A run may have multiple jobs.
RunID int64
// Action is the specific activity that triggered the event.
Action string `gorm:"type:varchar(254);index"`
// Conclusion is the outcome of the job.
// Possible values: "success", "failure", "neutral", "cancelled", "skipped",
// "timed_out", "action_required"
Conclusion string
// Status is the phase of the lifecycle that the job is currently in.
// "queued", "in_progress" and "completed".
Status string `gorm:"index:idx_workflow_jobs_status_instance_id,priority:1"`
// Name is the name if the job that was triggered.
Name string
StartedAt time.Time
CompletedAt time.Time
GithubRunnerID int64
InstanceID *uuid.UUID `gorm:"index:idx_instance_job;index:idx_workflow_jobs_status_instance_id,priority:2"`
Instance Instance `gorm:"foreignKey:InstanceID"`
RunnerGroupID int64
RunnerGroupName string
// repository in which the job was triggered.
RepositoryName string
RepositoryOwner string
Labels datatypes.JSON
WorkflowRunURL string
// The entity that received the hook.
//
// Webhooks may be configured on the repo, the org and/or the enterprise.
// If we only configure a repo to use garm, we'll only ever receive a
// webhook from the repo. But if we configure the parent org of the repo and
// the parent enterprise of the org to use garm, a webhook will be sent for each
// entity type, in response to one workflow event. Thus, we will get 3 webhooks
// with the same run_id and job id. Record all involved entities in the same job
// if we have them configured in garm.
RepoID *uuid.UUID `gorm:"index"`
Repository Repository `gorm:"foreignKey:RepoID"`
OrgID *uuid.UUID `gorm:"index"`
Organization Organization `gorm:"foreignKey:OrgID"`
EnterpriseID *uuid.UUID `gorm:"index"`
Enterprise Enterprise `gorm:"foreignKey:EnterpriseID"`
ForgeInstanceID *uuid.UUID `gorm:"index"`
ForgeInstance ForgeInstance `gorm:"foreignKey:ForgeInstanceID"`
// PoolID is set when one of the pool's runners picks up the job.
// Pools cannot know in advance which queued job a runner will service.
PoolID *uuid.UUID `gorm:"index"`
Pool Pool `gorm:"foreignKey:PoolID"`
LockedBy uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}