Documentation
¶
Index ¶
- Variables
- type ChangePayload
- type Consumer
- type ControllerStore
- type DatabaseEntityType
- type EnterpriseStore
- type EntityPoolStore
- type FileObjectStore
- type ForgeInstanceStore
- type GiteaCredentialsStore
- type GiteaEndpointStore
- type GithubCredentialsStore
- type GithubEndpointStore
- type InstanceStore
- type JobsStore
- type OperationType
- type OrgStore
- type PayloadFilterFunc
- type PoolStore
- type Producer
- type ProxyStore
- type RepoStore
- type ScaleSetInstanceStore
- type ScaleSetJobsStore
- type ScaleSetsStore
- type Store
- type TemplateStore
- type UserStore
- type Watcher
- type WatcherMetrics
Constants ¶
This section is empty.
Variables ¶
var ( ErrProducerClosed = fmt.Errorf("producer is closed") ErrProducerTimeoutErr = fmt.Errorf("producer timeout error") ErrProducerAlreadyRegistered = fmt.Errorf("producer already registered") ErrConsumerAlreadyRegistered = fmt.Errorf("consumer already registered") ErrWatcherAlreadyStarted = fmt.Errorf("watcher already started") ErrWatcherNotInitialized = fmt.Errorf("watcher not initialized") ErrInvalidOperationType = fmt.Errorf("invalid operation") ErrInvalidEntityType = fmt.Errorf("invalid entity type") ErrNoFiltersProvided = fmt.Errorf("no filters provided") )
Functions ¶
This section is empty.
Types ¶
type ChangePayload ¶ added in v0.1.5
type ChangePayload struct {
EntityType DatabaseEntityType `json:"entity-type"`
Operation OperationType `json:"operation"`
Payload interface{} `json:"payload"`
}
type Consumer ¶ added in v0.1.5
type Consumer interface {
Watch() <-chan ChangePayload
IsClosed() bool
Close()
SetFilters(filters ...PayloadFilterFunc)
}
type ControllerStore ¶ added in v0.1.5
type ControllerStore interface {
ControllerInfo(ctx context.Context) (params.ControllerInfo, error)
InitController(ctx context.Context) (params.ControllerInfo, error)
UpdateController(ctx context.Context, info params.UpdateControllerParams) (params.ControllerInfo, error)
HasEntitiesWithAgentModeEnabled(ctx context.Context) (bool, error)
UpdateCachedGARMAgentReleases(ctx context.Context, index []byte, fetchedAt time.Time) error
}
type DatabaseEntityType ¶ added in v0.1.5
type DatabaseEntityType string
const ( RepositoryEntityType DatabaseEntityType = "repository" OrganizationEntityType DatabaseEntityType = "organization" EnterpriseEntityType DatabaseEntityType = "enterprise" PoolEntityType DatabaseEntityType = "pool" UserEntityType DatabaseEntityType = "user" InstanceEntityType DatabaseEntityType = "instance" JobEntityType DatabaseEntityType = "job" ControllerEntityType DatabaseEntityType = "controller" GithubCredentialsEntityType DatabaseEntityType = "github_credentials" // #nosec G101 GiteaCredentialsEntityType DatabaseEntityType = "gitea_credentials" // #nosec G101 GithubEndpointEntityType DatabaseEntityType = "github_endpoint" ScaleSetEntityType DatabaseEntityType = "scaleset" ScaleSetJobEntityType DatabaseEntityType = "scaleset_job" TemplateEntityType DatabaseEntityType = "template" FileObjectEntityType DatabaseEntityType = "file_object" ForgeInstanceEntityType DatabaseEntityType = "forge_instance" ProxyEntityType DatabaseEntityType = "proxy" )
type EnterpriseStore ¶
type EnterpriseStore interface {
CreateEnterprise(ctx context.Context, name string, credentialsName params.ForgeCredentials, webhookSecret string, poolBalancerType params.PoolBalancerType, agentMode bool) (params.Enterprise, error)
GetEnterprise(ctx context.Context, name, endpointName string) (params.Enterprise, error)
GetEnterpriseByID(ctx context.Context, enterpriseID string) (params.Enterprise, error)
ListEnterprises(ctx context.Context, filter params.EnterpriseFilter) ([]params.Enterprise, error)
DeleteEnterprise(ctx context.Context, enterpriseID string) error
UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error)
}
type EntityPoolStore ¶ added in v0.1.5
type EntityPoolStore interface {
CreateEntityPool(ctx context.Context, entity params.ForgeEntity, param params.CreatePoolParams) (params.Pool, error)
GetEntityPool(ctx context.Context, entity params.ForgeEntity, poolID string) (params.Pool, error)
DeleteEntityPool(ctx context.Context, entity params.ForgeEntity, poolID string) error
UpdateEntityPool(ctx context.Context, entity params.ForgeEntity, poolID string, param params.UpdatePoolParams) (params.Pool, error)
ListEntityPools(ctx context.Context, entity params.ForgeEntity) ([]params.Pool, error)
ListEntityInstances(ctx context.Context, entity params.ForgeEntity) ([]params.Instance, error)
}
type FileObjectStore ¶ added in v0.2.0
type FileObjectStore interface {
ListFileObjects(ctx context.Context, page, pageSize uint64) (params.FileObjectPaginatedResponse, error)
SearchFileObjectByTags(ctx context.Context, tags []string, page, pageSize uint64) (params.FileObjectPaginatedResponse, error)
GetFileObject(ctx context.Context, objID uint) (params.FileObject, error)
CreateFileObject(ctx context.Context, param params.CreateFileObjectParams, reader io.Reader) (fileObjParam params.FileObject, err error)
UpdateFileObject(ctx context.Context, objID uint, param params.UpdateFileObjectParams) (params.FileObject, error)
DeleteFileObject(ctx context.Context, objID uint) error
DeleteFileObjectsByTags(ctx context.Context, tags []string) (int64, error)
OpenFileObjectContent(ctx context.Context, objID uint) (io.ReadCloser, error)
}
type ForgeInstanceStore ¶ added in v0.2.2
type ForgeInstanceStore interface {
CreateForgeInstance(ctx context.Context, endpointName string, credentials params.ForgeCredentials, webhookSecret string, poolBalancerType params.PoolBalancerType, agentMode bool) (params.ForgeInstance, error)
GetForgeInstance(ctx context.Context, endpointName string) (params.ForgeInstance, error)
GetForgeInstanceByID(ctx context.Context, forgeInstanceID string) (params.ForgeInstance, error)
ListForgeInstances(ctx context.Context, filter params.ForgeInstanceFilter) ([]params.ForgeInstance, error)
DeleteForgeInstance(ctx context.Context, forgeInstanceID string) error
UpdateForgeInstance(ctx context.Context, forgeInstanceID string, param params.UpdateEntityParams) (params.ForgeInstance, error)
}
type GiteaCredentialsStore ¶ added in v0.2.0
type GiteaCredentialsStore interface {
CreateGiteaCredentials(ctx context.Context, param params.CreateGiteaCredentialsParams) (gtCreds params.ForgeCredentials, err error)
GetGiteaCredentialsByName(ctx context.Context, name string, detailed bool) (params.ForgeCredentials, error)
GetGiteaCredentials(ctx context.Context, id uint, detailed bool) (params.ForgeCredentials, error)
ListGiteaCredentials(ctx context.Context) ([]params.ForgeCredentials, error)
UpdateGiteaCredentials(ctx context.Context, id uint, param params.UpdateGiteaCredentialsParams) (gtCreds params.ForgeCredentials, err error)
DeleteGiteaCredentials(ctx context.Context, id uint) (err error)
}
type GiteaEndpointStore ¶ added in v0.2.0
type GiteaEndpointStore interface {
CreateGiteaEndpoint(ctx context.Context, param params.CreateGiteaEndpointParams) (ghEndpoint params.ForgeEndpoint, err error)
ListGiteaEndpoints(ctx context.Context) ([]params.ForgeEndpoint, error)
DeleteGiteaEndpoint(ctx context.Context, name string) (err error)
GetGiteaEndpoint(ctx context.Context, name string) (params.ForgeEndpoint, error)
UpdateGiteaEndpoint(ctx context.Context, name string, param params.UpdateGiteaEndpointParams) (ghEndpoint params.ForgeEndpoint, err error)
}
type GithubCredentialsStore ¶ added in v0.1.5
type GithubCredentialsStore interface {
CreateGithubCredentials(ctx context.Context, param params.CreateGithubCredentialsParams) (params.ForgeCredentials, error)
GetGithubCredentials(ctx context.Context, id uint, detailed bool) (params.ForgeCredentials, error)
GetGithubCredentialsByName(ctx context.Context, name string, detailed bool) (params.ForgeCredentials, error)
ListGithubCredentials(ctx context.Context) ([]params.ForgeCredentials, error)
UpdateGithubCredentials(ctx context.Context, id uint, param params.UpdateGithubCredentialsParams) (params.ForgeCredentials, error)
DeleteGithubCredentials(ctx context.Context, id uint) error
}
type GithubEndpointStore ¶ added in v0.1.5
type GithubEndpointStore interface {
CreateGithubEndpoint(ctx context.Context, param params.CreateGithubEndpointParams) (params.ForgeEndpoint, error)
GetGithubEndpoint(ctx context.Context, name string) (params.ForgeEndpoint, error)
ListGithubEndpoints(ctx context.Context) ([]params.ForgeEndpoint, error)
UpdateGithubEndpoint(ctx context.Context, name string, param params.UpdateGithubEndpointParams) (params.ForgeEndpoint, error)
DeleteGithubEndpoint(ctx context.Context, name string) error
}
type InstanceStore ¶
type InstanceStore interface {
CreateInstance(ctx context.Context, poolID string, param params.CreateInstanceParams) (params.Instance, error)
DeleteInstance(ctx context.Context, poolID string, instanceNameOrID string) error
DeleteInstanceByName(ctx context.Context, instanceName string) error
UpdateInstance(ctx context.Context, instanceNameOrID string, param params.UpdateInstanceParams) (params.Instance, error)
// ForceUpdateInstance functions identically to UpdateInstance with one important distinction. It does not
// validate the agent ID or instance status or runner status transitions. This function must only be used in
// recovery scenarios, where GARM crashed or was restarted while runners were going through a transitory
// state like "creating", "deleting", etc. In such cases, we cannot simply pick up where we left off, and
// we must set the instance in "pending_delete" or some other state that allows us to recover.
// An instance in "creating" state is currently being serviced by a call by GARM to the external provider.
// If GARM is just starting up and we see one in "creating", it means that the process that was creating it
// was most likely interrupted before it finished and we must clean it up.
ForceUpdateInstance(ctx context.Context, instanceName string, param params.UpdateInstanceParams) (params.Instance, error)
// Probably a bad idea without some king of filter or at least pagination
//
// nolint:golangci-lint,godox
// TODO: add filter/pagination
ListAllInstances(ctx context.Context) ([]params.Instance, error)
GetInstance(ctx context.Context, instanceNameOrID string) (params.Instance, error)
AddInstanceEvent(ctx context.Context, instanceNameOrID string, event params.EventType, eventLevel params.EventLevel, eventMessage string) error
}
type JobsStore ¶ added in v0.1.2
type JobsStore interface {
CreateOrUpdateJob(ctx context.Context, job params.Job) (params.Job, error)
ListEntityJobsByStatus(ctx context.Context, entityType params.ForgeEntityType, entityID string, status params.JobStatus) ([]params.Job, error)
ListJobsByStatus(ctx context.Context, status params.JobStatus) ([]params.Job, error)
ListAllJobs(ctx context.Context) ([]params.Job, error)
ListJobs(ctx context.Context, filter params.ListJobsFilter) (params.JobsPaginatedResponse, error)
GetJobByID(ctx context.Context, jobID int64) (params.Job, error)
DeleteJob(ctx context.Context, jobID int64) error
UnlockJob(ctx context.Context, jobID int64, entityID string) error
LockJob(ctx context.Context, jobID int64, entityID string) error
BreakLockJobIsQueued(ctx context.Context, jobID int64) error
DeleteInactionableJobs(ctx context.Context, olderThan time.Duration) error
}
type OperationType ¶ added in v0.1.5
type OperationType string
const ( CreateOperation OperationType = "create" UpdateOperation OperationType = "update" DeleteOperation OperationType = "delete" )
type OrgStore ¶
type OrgStore interface {
CreateOrganization(ctx context.Context, name string, credentials params.ForgeCredentials, webhookSecret string, poolBalancerType params.PoolBalancerType, agentMode bool) (org params.Organization, err error)
GetOrganization(ctx context.Context, name, endpointName string) (params.Organization, error)
GetOrganizationByID(ctx context.Context, orgID string) (params.Organization, error)
ListOrganizations(ctx context.Context, filter params.OrganizationFilter) ([]params.Organization, error)
DeleteOrganization(ctx context.Context, orgID string) error
UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (params.Organization, error)
}
type PayloadFilterFunc ¶ added in v0.1.5
type PayloadFilterFunc func(ChangePayload) bool
type PoolStore ¶
type PoolStore interface {
// Probably a bad idea without some king of filter or at least pagination
// nolint:golangci-lint,godox
// TODO: add filter/pagination
ListAllPools(ctx context.Context) ([]params.Pool, error)
GetPoolByID(ctx context.Context, poolID string) (params.Pool, error)
DeletePoolByID(ctx context.Context, poolID string) error
ListPoolInstances(ctx context.Context, poolID string, oudatedOnly bool) ([]params.Instance, error)
PoolInstanceCount(ctx context.Context, poolID string) (int64, error)
FindPoolsMatchingAllTags(ctx context.Context, entityType params.ForgeEntityType, entityID string, tags []string) ([]params.Pool, error)
}
type Producer ¶ added in v0.1.5
type Producer interface {
Notify(ChangePayload) error
IsClosed() bool
Close()
}
type ProxyStore ¶ added in v0.2.2
type ProxyStore interface {
ListProxies(ctx context.Context) ([]params.Proxy, error)
CreateProxy(ctx context.Context, param params.CreateProxyParams) (proxy params.Proxy, err error)
GetProxy(ctx context.Context, id uint) (params.Proxy, error)
GetProxyByName(ctx context.Context, name string) (params.Proxy, error)
UpdateProxy(ctx context.Context, id uint, param params.UpdateProxyParams) (proxy params.Proxy, err error)
DeleteProxy(ctx context.Context, id uint) (err error)
}
type RepoStore ¶
type RepoStore interface {
CreateRepository(ctx context.Context, owner, name string, credentials params.ForgeCredentials, webhookSecret string, poolBalancerType params.PoolBalancerType, agentMode bool) (param params.Repository, err error)
GetRepository(ctx context.Context, owner, name, endpointName string) (params.Repository, error)
GetRepositoryByID(ctx context.Context, repoID string) (params.Repository, error)
ListRepositories(ctx context.Context, filter params.RepositoryFilter) ([]params.Repository, error)
DeleteRepository(ctx context.Context, repoID string) error
UpdateRepository(ctx context.Context, repoID string, param params.UpdateEntityParams) (params.Repository, error)
}
type ScaleSetInstanceStore ¶ added in v0.2.0
type ScaleSetJobsStore ¶ added in v0.2.2
type ScaleSetJobsStore interface {
CreateOrUpdateScaleSetJob(ctx context.Context, job params.ScaleSetJob) (params.ScaleSetJob, error)
ListScaleSetJobs(ctx context.Context, scaleSetID uint) ([]params.ScaleSetJob, error)
ListAllScaleSetJobs(ctx context.Context) ([]params.ScaleSetJob, error)
// ListScaleSetJobsPaginated filters and paginates the scale set job
// ledger. A zero scaleSetID lists jobs across all scale sets.
ListScaleSetJobsPaginated(ctx context.Context, scaleSetID uint, filter params.ListJobsFilter) (params.ScaleSetJobsPaginatedResponse, error)
DeleteOldScaleSetJobs(ctx context.Context, olderThan time.Duration) error
}
ScaleSetJobsStore manages the informational ledger of jobs GitHub routed to scale sets. GARM records these as it sees them on each scale set's message queue. Nothing acts on them.
type ScaleSetsStore ¶ added in v0.2.0
type ScaleSetsStore interface {
ListAllScaleSets(ctx context.Context) ([]params.ScaleSet, error)
CreateEntityScaleSet(ctx context.Context, entity params.ForgeEntity, param params.CreateScaleSetParams) (scaleSet params.ScaleSet, err error)
ListEntityScaleSets(ctx context.Context, entity params.ForgeEntity) ([]params.ScaleSet, error)
UpdateEntityScaleSet(ctx context.Context, entity params.ForgeEntity, scaleSetID uint, param params.UpdateScaleSetParams, callback func(old, newSet params.ScaleSet) error) (updatedScaleSet params.ScaleSet, err error)
GetScaleSetByID(ctx context.Context, scaleSet uint) (params.ScaleSet, error)
DeleteScaleSetByID(ctx context.Context, scaleSetID uint) (err error)
SetScaleSetLastMessageID(ctx context.Context, scaleSetID uint, lastMessageID int64) error
SetScaleSetDesiredRunnerCount(ctx context.Context, scaleSetID uint, desiredRunnerCount int) error
}
type Store ¶
type Store interface {
RepoStore
OrgStore
EnterpriseStore
ForgeInstanceStore
PoolStore
UserStore
InstanceStore
JobsStore
ScaleSetJobsStore
GithubEndpointStore
GithubCredentialsStore
ControllerStore
EntityPoolStore
ScaleSetsStore
ScaleSetInstanceStore
GiteaEndpointStore
GiteaCredentialsStore
TemplateStore
ProxyStore
FileObjectStore
ControllerInfo(ctx context.Context) (params.ControllerInfo, error)
InitController(ctx context.Context) (params.ControllerInfo, error)
GetForgeEntity(ctx context.Context, entityType params.ForgeEntityType, entityID string) (params.ForgeEntity, error)
AddEntityEvent(ctx context.Context, entity params.ForgeEntity, event params.EventType, eventLevel params.EventLevel, statusMessage string, maxEvents int) error
SetEntityPoolManagerStatus(ctx context.Context, entity params.ForgeEntity, param params.PoolManagerStatus) error
}
type TemplateStore ¶ added in v0.2.0
type TemplateStore interface {
ListTemplates(ctx context.Context, osType *commonParams.OSType, forgeType *params.EndpointType, partialName *string) ([]params.Template, error)
CreateTemplate(ctx context.Context, param params.CreateTemplateParams) (template params.Template, err error)
GetTemplate(ctx context.Context, id uint) (params.Template, error)
GetTemplateByName(ctx context.Context, name string) (params.Template, error)
UpdateTemplate(ctx context.Context, id uint, param params.UpdateTemplateParams) (template params.Template, err error)
DeleteTemplate(ctx context.Context, id uint) (err error)
}
type UserStore ¶
type UserStore interface {
GetUser(ctx context.Context, user string) (params.User, error)
GetUserByID(ctx context.Context, userID string) (params.User, error)
GetAdminUser(ctx context.Context) (params.User, error)
CreateUser(ctx context.Context, user params.NewUserParams) (params.User, error)
UpdateUser(ctx context.Context, user string, param params.UpdateUserParams) (params.User, error)
HasAdminUser(ctx context.Context) bool
}
type WatcherMetrics ¶ added in v0.2.2
type WatcherMetrics struct {
// ConsumerQueueDepths maps each registered consumer ID to the number of
// events queued for it and not yet delivered.
ConsumerQueueDepths map[string]int
}
WatcherMetrics holds a point-in-time snapshot of the watcher's internal state, for consumption by the metrics layer.