datastore

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	Nano    ResourceType = "nano"
	Micro                = "micro"
	Small                = "small"
	Medium               = "medium"
	Large                = "large"
	XLarge               = "xlarge"
	XLarge2              = "2xlarge"
	XLarge3              = "3xlarge"
	XLarge4              = "4xlarge"
)

ResourceTypes variables

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 string

ResourceType is runner machine spec

func (*ResourceType) String

func (r *ResourceType) String() string

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