common

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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() (params.ControllerInfo, error)
	InitController() (params.ControllerInfo, error)
	UpdateController(info params.UpdateControllerParams) (params.ControllerInfo, 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
	GithubEndpointEntityType    DatabaseEntityType = "github_endpoint"
)

type EnterpriseStore

type EnterpriseStore interface {
	CreateEnterprise(ctx context.Context, name, credentialsName, webhookSecret string, poolBalancerType params.PoolBalancerType) (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) ([]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.GithubEntity, param params.CreatePoolParams) (params.Pool, error)
	GetEntityPool(ctx context.Context, entity params.GithubEntity, poolID string) (params.Pool, error)
	DeleteEntityPool(ctx context.Context, entity params.GithubEntity, poolID string) error
	UpdateEntityPool(ctx context.Context, entity params.GithubEntity, poolID string, param params.UpdatePoolParams) (params.Pool, error)

	ListEntityPools(ctx context.Context, entity params.GithubEntity) ([]params.Pool, error)
	ListEntityInstances(ctx context.Context, entity params.GithubEntity) ([]params.Instance, error)
}

type GithubCredentialsStore added in v0.1.5

type GithubCredentialsStore interface {
	CreateGithubCredentials(ctx context.Context, param params.CreateGithubCredentialsParams) (params.GithubCredentials, error)
	GetGithubCredentials(ctx context.Context, id uint, detailed bool) (params.GithubCredentials, error)
	GetGithubCredentialsByName(ctx context.Context, name string, detailed bool) (params.GithubCredentials, error)
	ListGithubCredentials(ctx context.Context) ([]params.GithubCredentials, error)
	UpdateGithubCredentials(ctx context.Context, id uint, param params.UpdateGithubCredentialsParams) (params.GithubCredentials, 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.GithubEndpoint, error)
	GetGithubEndpoint(ctx context.Context, name string) (params.GithubEndpoint, error)
	ListGithubEndpoints(ctx context.Context) ([]params.GithubEndpoint, error)
	UpdateGithubEndpoint(ctx context.Context, name string, param params.UpdateGithubEndpointParams) (params.GithubEndpoint, 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, instanceName string) error
	UpdateInstance(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)

	GetInstanceByName(ctx context.Context, instanceName string) (params.Instance, error)
	AddInstanceEvent(ctx context.Context, instanceName 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.GithubEntityType, 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)

	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

	DeleteCompletedJobs(ctx context.Context) 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, credentialsName, webhookSecret string, poolBalancerType params.PoolBalancerType) (params.Organization, error)
	GetOrganization(ctx context.Context, name, endpointName string) (params.Organization, error)
	GetOrganizationByID(ctx context.Context, orgID string) (params.Organization, error)
	ListOrganizations(ctx context.Context) ([]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) ([]params.Instance, error)

	PoolInstanceCount(ctx context.Context, poolID string) (int64, error)
	GetPoolInstanceByName(ctx context.Context, poolID string, instanceName string) (params.Instance, error)
	FindPoolsMatchingAllTags(ctx context.Context, entityType params.GithubEntityType, entityID string, tags []string) ([]params.Pool, error)
}

type Producer added in v0.1.5

type Producer interface {
	Notify(ChangePayload) error
	IsClosed() bool
	Close()
}

type RepoStore

type RepoStore interface {
	CreateRepository(ctx context.Context, owner, name, credentialsName, webhookSecret string, poolBalancerType params.PoolBalancerType) (params.Repository, 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) ([]params.Repository, error)
	DeleteRepository(ctx context.Context, repoID string) error
	UpdateRepository(ctx context.Context, repoID string, param params.UpdateEntityParams) (params.Repository, 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 Watcher added in v0.1.5

type Watcher interface {
	RegisterProducer(ctx context.Context, ID string) (Producer, error)
	RegisterConsumer(ctx context.Context, ID string, filters ...PayloadFilterFunc) (Consumer, error)
	Close()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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