sql

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSQLDatabase

func NewSQLDatabase(ctx context.Context, cfg config.Database) (common.Store, error)

Types

type Address

type Address struct {
	Base

	Address string
	Type    string

	InstanceID uuid.UUID
	Instance   Instance `gorm:"foreignKey:InstanceID"`
}

type Base

type Base struct {
	ID        uuid.UUID `gorm:"type:uuid;primary_key;"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func (*Base) BeforeCreate

func (b *Base) BeforeCreate(tx *gorm.DB) error

type ControllerInfo

type ControllerInfo struct {
	Base

	ControllerID uuid.UUID
}

type Enterprise

type Enterprise struct {
	Base

	CredentialsName string
	Name            string `gorm:"index:idx_ent_name_nocase,collate:nocase"`
	WebhookSecret   []byte
	Pools           []Pool `gorm:"foreignKey:EnterpriseID"`
}

type Instance

type Instance struct {
	Base

	ProviderID        *string `gorm:"uniqueIndex"`
	Name              string  `gorm:"uniqueIndex"`
	AgentID           int64
	OSType            params.OSType
	OSArch            params.OSArch
	OSName            string
	OSVersion         string
	Addresses         []Address `gorm:"foreignKey:InstanceID"`
	Status            common.InstanceStatus
	RunnerStatus      common.RunnerStatus
	CallbackURL       string
	MetadataURL       string
	ProviderFault     []byte `gorm:"type:longblob"`
	CreateAttempt     int
	TokenFetched      bool
	GitHubRunnerGroup string

	PoolID uuid.UUID
	Pool   Pool `gorm:"foreignKey:PoolID"`

	StatusMessages []InstanceStatusUpdate `gorm:"foreignKey:InstanceID"`
}

type InstanceStatusUpdate

type InstanceStatusUpdate struct {
	Base

	EventType  params.EventType `gorm:"index:eventType"`
	EventLevel params.EventLevel
	Message    string `gorm:"type:text"`

	InstanceID uuid.UUID
	Instance   Instance `gorm:"foreignKey:InstanceID"`
}

type Organization

type Organization struct {
	Base

	CredentialsName string
	Name            string `gorm:"index:idx_org_name_nocase,collate:nocase"`
	WebhookSecret   []byte
	Pools           []Pool `gorm:"foreignKey:OrgID"`
}

type Pool

type Pool struct {
	Base

	ProviderName           string `gorm:"index:idx_pool_type"`
	RunnerPrefix           string
	MaxRunners             uint
	MinIdleRunners         uint
	RunnerBootstrapTimeout uint
	Image                  string `gorm:"index:idx_pool_type"`
	Flavor                 string `gorm:"index:idx_pool_type"`
	OSType                 params.OSType
	OSArch                 params.OSArch
	Tags                   []*Tag `gorm:"many2many:pool_tags;"`
	Enabled                bool
	// ExtraSpecs is an opaque json that gets sent to the provider
	// as part of the bootstrap params for instances. It can contain
	// any kind of data needed by providers.
	ExtraSpecs        datatypes.JSON
	GitHubRunnerGroup string

	RepoID     uuid.UUID  `gorm:"index"`
	Repository Repository `gorm:"foreignKey:RepoID"`

	OrgID        uuid.UUID    `gorm:"index"`
	Organization Organization `gorm:"foreignKey:OrgID"`

	EnterpriseID uuid.UUID  `gorm:"index"`
	Enterprise   Enterprise `gorm:"foreignKey:EnterpriseID"`

	Instances []Instance `gorm:"foreignKey:PoolID"`
}

type Repository

type Repository struct {
	Base

	CredentialsName string
	Owner           string `gorm:"index:idx_owner_nocase,unique,collate:nocase"`
	Name            string `gorm:"index:idx_owner_nocase,unique,collate:nocase"`
	WebhookSecret   []byte
	Pools           []Pool `gorm:"foreignKey:RepoID"`
}

type Tag

type Tag struct {
	Base

	Name  string  `gorm:"type:varchar(64);uniqueIndex"`
	Pools []*Pool `gorm:"many2many:pool_tags;"`
}

type User

type User struct {
	Base

	Username string `gorm:"uniqueIndex;varchar(64)"`
	FullName string `gorm:"type:varchar(254)"`
	Email    string `gorm:"type:varchar(254);unique;index:idx_email"`
	Password string `gorm:"type:varchar(60)"`
	IsAdmin  bool
	Enabled  bool
}

Jump to

Keyboard shortcuts

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