Documentation ¶
Index ¶
Constants ¶
const ( TargetStatusActive TargetStatus = "active" //lint:ignore SA9004 this is status TargetStatusRunning = "running" TargetStatusSuspend = "suspend" TargetStatusDeleted = "deleted" TargetStatusErr = "error" )
TargetStatus variables
const ( RunnerStatusCreated RunnerStatus = "created" //lint:ignore SA9004 this is status RunnerStatusCompleted = "completed" RunnerStatusReachHardLimit = "reach_hard_limit" )
RunnerStatus variables
Variables ¶
var ( IsLocked = "is locked" IsNotLocked = "is not locked" )
Lock values
var (
ErrNotFound = errors.New("not found")
)
Error values
Functions ¶
func UpdateTargetStatus ¶ added in v1.4.2
func UpdateTargetStatus(ctx context.Context, ds Datastore, targetID uuid.UUID, newStatus TargetStatus, description string) error
UpdateTargetStatus update datastore
Types ¶
type Datastore ¶
type Datastore interface { CreateTarget(ctx context.Context, target Target) error GetTarget(ctx context.Context, id uuid.UUID) (*Target, error) GetTargetByScope(ctx context.Context, scope string) (*Target, error) ListTargets(ctx context.Context) ([]Target, error) DeleteTarget(ctx context.Context, id uuid.UUID) error // Deprecated: Use datastore.UpdateTargetStatus. UpdateTargetStatus(ctx context.Context, targetID uuid.UUID, newStatus TargetStatus, description string) error UpdateToken(ctx context.Context, targetID uuid.UUID, newToken string, newExpiredAt time.Time) error UpdateTargetParam(ctx context.Context, targetID uuid.UUID, newResourceType ResourceType, newProviderURL sql.NullString) error EnqueueJob(ctx context.Context, job Job) error ListJobs(ctx context.Context) ([]Job, error) DeleteJob(ctx context.Context, id uuid.UUID) error CreateRunner(ctx context.Context, runner Runner) error ListRunners(ctx context.Context) ([]Runner, error) ListRunnersByTargetID(ctx context.Context, targetID uuid.UUID) ([]Runner, error) GetRunner(ctx context.Context, id uuid.UUID) (*Runner, error) DeleteRunner(ctx context.Context, id uuid.UUID, deletedAt time.Time, reason RunnerStatus) error // Lock GetLock(ctx context.Context) error IsLocked(ctx context.Context) (string, error) }
Datastore is persistent storage
type Job ¶
type Job struct { UUID uuid.UUID `db:"uuid"` GHEDomain sql.NullString `db:"ghe_domain"` Repository string `db:"repository"` // repo (:owner/:repo) CheckEventJSON string `db:"check_event"` TargetID uuid.UUID `db:"target_id"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
Job is a runner job
type ResourceType ¶
type ResourceType int
ResourceType is runner machine spec
const ( ResourceTypeUnknown ResourceType = iota ResourceTypeNano ResourceTypeMicro ResourceTypeSmall ResourceTypeMedium ResourceTypeLarge ResourceTypeXLarge ResourceType2XLarge ResourceType3XLarge ResourceType4XLarge )
ResourceTypes variables
func UnmarshalResourceType ¶ added in v1.2.1
func UnmarshalResourceType(src interface{}) ResourceType
UnmarshalResourceType cast type to ResourceType
func UnmarshalResourceTypePb ¶ added in v1.2.1
func UnmarshalResourceTypePb(in pb.ResourceType) ResourceType
UnmarshalResourceTypePb cast type from pb.ResourceType to ResourceType
func UnmarshalResourceTypeString ¶ added in v1.2.1
func UnmarshalResourceTypeString(in string) ResourceType
UnmarshalResourceTypeString cast type from string to ResourceType
func (ResourceType) MarshalJSON ¶ added in v1.4.1
func (r ResourceType) MarshalJSON() ([]byte, error)
MarshalJSON implements the encoding/json Marshaler interface
func (*ResourceType) Scan ¶ added in v1.2.1
func (r *ResourceType) Scan(src interface{}) error
Scan implements the database/sql Scanner interface
func (ResourceType) String ¶
func (r ResourceType) String() string
String implement interface for fmt.Stringer
func (ResourceType) ToPb ¶ added in v1.2.0
func (r ResourceType) ToPb() pb.ResourceType
ToPb convert type of protobuf
func (*ResourceType) UnmarshalJSON ¶ added in v1.4.1
func (r *ResourceType) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the encoding/json Unmarshaler interface
type Runner ¶
type Runner struct { UUID uuid.UUID `db:"runner_id"` ShoesType string `db:"shoes_type"` IPAddress string `db:"ip_address"` TargetID uuid.UUID `db:"target_id"` CloudID string `db:"cloud_id"` Deleted bool `db:"deleted"` Status RunnerStatus `db:"status"` ResourceType ResourceType `db:"resource_type"` RunnerUser sql.NullString `db:"runner_user" json:"runner_user"` ProviderURL sql.NullString `db:"provider_url" json:"provider_url"` RepositoryURL string `db:"repository_url"` RequestWebhook string `db:"request_webhook"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` DeletedAt sql.NullTime `db:"deleted_at"` }
Runner is a runner
type Target ¶
type Target struct { UUID uuid.UUID `db:"uuid" json:"id"` Scope string `db:"scope" json:"scope"` // repo (:owner/:repo) or org (:organization) // deprecated GitHubToken string `db:"github_token" json:"github_token"` TokenExpiredAt time.Time `db:"token_expired_at" json:"token_expired_at"` GHEDomain sql.NullString `db:"ghe_domain" json:"ghe_domain"` ResourceType ResourceType `db:"resource_type" json:"resource_type"` ProviderURL sql.NullString `db:"provider_url" json:"provider_url"` Status TargetStatus `db:"status" json:"status"` StatusDescription sql.NullString `db:"status_description" json:"status_description"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` }
Target is a target repository that will add auto-scaling runner.
func ListTargets ¶ added in v1.6.2
ListTargets get list of target that can receive job
func SearchRepo ¶ added in v1.15.1
SearchRepo search datastore.Target from datastore format of repo is "orgs/repos"
func (*Target) CanReceiveJob ¶ added in v1.4.0
CanReceiveJob check status in target