datastore

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	TargetStatusInitialize Status = "initialize"
	TargetStatusActive            = "active"
	TargetStatusRunning           = "running"
	TargetStatusErr               = "error"
)

Status variables

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Error values

Functions

This section is empty.

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, gheDomain, scope string) (*Target, error)
	ListTargets(ctx context.Context) ([]Target, error)
	DeleteTarget(ctx context.Context, id uuid.UUID) error

	UpdateStatus(ctx context.Context, targetID uuid.UUID, newStatus Status, description string) 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)
	GetRunner(ctx context.Context, id uuid.UUID) (*Runner, error)
	DeleteRunner(ctx context.Context, id uuid.UUID, deletedAt time.Time) 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.ResourType to ResourceType

func UnmarshalResourceTypeString added in v1.2.1

func UnmarshalResourceTypeString(in string) ResourceType

UnmarshalResourceTypeString cast type from string to ResourceType

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) Value added in v1.2.1

func (r ResourceType) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type Runner

type Runner struct {
	UUID      uuid.UUID    `db:"uuid"`
	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"`
	CreatedAt time.Time    `db:"created_at"`
	UpdatedAt time.Time    `db:"updated_at"`
	DeletedAt sql.NullTime `db:"deleted_at"`
}

Runner is a runner

type Status

type Status string

Status is status for target

type Target

type Target struct {
	UUID                uuid.UUID      `db:"uuid" json:"id"`
	Scope               string         `db:"scope" json:"scope"`                                 // repo (:owner/:repo) or org (:organization)
	GitHubPersonalToken string         `db:"github_personal_token" json:"github_personal_token"` // TODO: encrypt
	GHEDomain           sql.NullString `db:"ghe_domain" json:"ghe_domain"`
	ResourceType        ResourceType   `db:"resource_type" json:"resource_type"`
	RunnerUser          sql.NullString `db:"runner_user" json:"runner_user"`
	Status              Status         `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 (*Target) OwnerRepo

func (t *Target) OwnerRepo() (string, string)

OwnerRepo return :owner and :repo

func (*Target) RepoURL

func (t *Target) RepoURL() string

RepoURL return repository URL.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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