db

package
v0.0.0-...-9d58fce Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRecordNotFoundError

func IsRecordNotFoundError(err error) bool

IsRecordNotFoundError returns true if the error is a record not found error.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(dialect Dialect, conn *gorm.DB) *Client

NewClient creates a new database client.

func NewMockDB

func NewMockDB(t *testing.T) *Client

NewMockDB creates a new database with tables created from given models. It uses sqlite in memory as the database.

func (*Client) CreateJobs

func (c *Client) CreateJobs(ctx context.Context, options []*CreateJobOption) ([]*Job, error)

func (*Client) CreatePipeline

func (c *Client) CreatePipeline(ctx context.Context, opt *CreatePipelineOption) (*Pipeline, error)

CreatePipeline creates a new pipeline.

func (*Client) GetJobByRunnerExecutionID

func (c *Client) GetJobByRunnerExecutionID(ctx context.Context, runnerExecutionID int64) (*Job, error)

func (*Client) GetPipelineByID

func (c *Client) GetPipelineByID(ctx context.Context, id int64) (*Pipeline, error)

GetPipelineByID gets a pipeline by ID.

type CreateJobOption

type CreateJobOption struct {
	PipelineID           int64
	Name                 string
	UID                  string
	Steps                []*Step
	CheckRunID           int64
	RunnerJobExecutionID int64
}

type CreatePipelineOption

type CreatePipelineOption struct {
	AppInstallID int64
	RepoOwner    string
	RepoName     string
	HeadSHA      string
}

type Dialect

type Dialect string
const (
	Postgres Dialect = "postgres"
	SQLite   Dialect = "sqlite"
	Mysql    Dialect = "mysql"
)

type Job

type Job struct {
	ID                   int64     `gorm:"column:id;primaryKey;autoIncrement"`
	UID                  string    `gorm:"column:uid"`
	Name                 string    `gorm:"column:name"`
	Steps                []byte    `gorm:"column:steps"`
	PipelineID           int64     `gorm:"column:pipeline_id"`
	CheckRunID           int64     `gorm:"column:check_run_id"`
	RunnerJobExecutionID int64     `gorm:"column:runner_job_execution_id"`
	CreatedAt            time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt            time.Time `gorm:"column:updated_at;autoUpdateTime"`
}

func (*Job) TableName

func (p *Job) TableName() string

type Pipeline

type Pipeline struct {
	ID           int64     `gorm:"column:id;primaryKey;autoIncrement"`
	AppInstallID int64     `gorm:"column:app_install_id"`
	RepoOwner    string    `gorm:"column:repo_owner"`
	RepoName     string    `gorm:"column:repo_name"`
	HeadSHA      string    `gorm:"column:head_sha"`
	CreatedAt    time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt    time.Time `gorm:"column:updated_at;autoUpdateTime"`
}

func (*Pipeline) TableName

func (p *Pipeline) TableName() string

type Step

type Step struct {
	Name string `json:"name"`
}

Step is a snapshot of StepDSL

Jump to

Keyboard shortcuts

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