build

package
v0.27.4 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreateCreatedIndex represents a query to create an
	// index on the builds table for the created column.
	CreateCreatedIndex = `
CREATE INDEX
IF NOT EXISTS
builds_created
ON builds (created);
`

	// CreateEventIndex represents a query to create an
	// index on the builds table for the event column.
	CreateEventIndex = `
CREATE INDEX
IF NOT EXISTS
builds_event
ON builds (event);
`

	// CreateRepoIDIndex represents a query to create an
	// index on the builds table for the repo_id column.
	CreateRepoIDIndex = `
CREATE INDEX
IF NOT EXISTS
builds_repo_id
ON builds (repo_id);
`

	// CreateStatusIndex represents a query to create an
	// index on the builds table for the status column.
	CreateStatusIndex = `
CREATE INDEX
IF NOT EXISTS
builds_status
ON builds (status);
`
)
View Source
const (
	// CreatePostgresTable represents a query to create the Postgres builds table.
	CreatePostgresTable = `` /* 1150-byte string literal not displayed */

	// CreateSqliteTable represents a query to create the Sqlite builds table.
	CreateSqliteTable = `` /* 966-byte string literal not displayed */

)

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildInterface

type BuildInterface interface {

	// CreateBuildIndexes defines a function that creates the indexes for the builds table.
	CreateBuildIndexes(context.Context) error
	// CreateBuildTable defines a function that creates the builds table.
	CreateBuildTable(context.Context, string) error

	// CleanBuilds defines a function that sets pending or running builds to error created before a given time.
	CleanBuilds(context.Context, string, int64) (int64, error)
	// CountBuilds defines a function that gets the count of all builds.
	CountBuilds(context.Context) (int64, error)
	// CountBuildsForDeployment defines a function that gets the count of builds by deployment url.
	CountBuildsForDeployment(context.Context, *api.Deployment, map[string]interface{}) (int64, error)
	// CountBuildsForOrg defines a function that gets the count of builds by org name.
	CountBuildsForOrg(context.Context, string, map[string]interface{}) (int64, error)
	// CountBuildsForRepo defines a function that gets the count of builds by repo ID.
	CountBuildsForRepo(context.Context, *api.Repo, map[string]interface{}, int64, int64) (int64, error)
	// CountBuildsForStatus defines a function that gets the count of builds by status.
	CountBuildsForStatus(context.Context, string, map[string]interface{}) (int64, error)
	// CreateBuild defines a function that creates a new build.
	CreateBuild(context.Context, *api.Build) (*api.Build, error)
	// DeleteBuild defines a function that deletes an existing build.
	DeleteBuild(context.Context, *api.Build) error
	// GetBuild defines a function that gets a build by ID.
	GetBuild(context.Context, int64) (*api.Build, error)
	// GetBuildForRepo defines a function that gets a build by repo ID and number.
	GetBuildForRepo(context.Context, *api.Repo, int64) (*api.Build, error)
	// LastBuildForRepo defines a function that gets the last build ran by repo ID and branch.
	LastBuildForRepo(context.Context, *api.Repo, string) (*api.Build, error)
	// ListBuilds defines a function that gets a list of all builds.
	ListBuilds(context.Context) ([]*api.Build, error)
	// ListBuildsForOrg defines a function that gets a list of builds by org name.
	ListBuildsForOrg(context.Context, string, map[string]any, map[string]any, int, int) ([]*api.Build, error)
	// ListBuildsForDashboardRepo defines a function that gets a list of builds based on dashboard filters.
	ListBuildsForDashboardRepo(context.Context, *api.Repo, []string, []string) ([]*api.Build, error)
	// ListBuildsForRepo defines a function that gets a list of builds by repo ID.
	ListBuildsForRepo(context.Context, *api.Repo, map[string]interface{}, int64, int64, int, int) ([]*api.Build, error)
	// ListPendingAndRunningBuilds defines a function that gets a list of pending and running builds.
	ListPendingAndRunningBuilds(context.Context, string) ([]*api.QueueBuild, error)
	// ListPendingAndRunningBuildsForRepo defines a function that gets a list of pending and running builds for a repo.
	ListPendingAndRunningBuildsForRepo(context.Context, *api.Repo) ([]*api.Build, error)
	// ListPendingApprovalBuilds defines a function that gets a list of pending approval builds that were created before a given time.
	ListPendingApprovalBuilds(context.Context, string) ([]*api.Build, error)
	// UpdateBuild defines a function that updates an existing build.
	UpdateBuild(context.Context, *api.Build) (*api.Build, error)
}

type Engine added in v0.27.0

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

Engine represents the build functionality that implements the BuildInterface interface.

func New

func New(opts ...EngineOpt) (*Engine, error)

New creates and returns a Vela service for integrating with builds in the database.

func (*Engine) CleanBuilds added in v0.27.0

func (e *Engine) CleanBuilds(ctx context.Context, msg string, before int64) (int64, error)

CleanBuilds updates builds to an error with a provided message with a created timestamp prior to a defined moment.

func (*Engine) CountBuilds added in v0.27.0

func (e *Engine) CountBuilds(ctx context.Context) (int64, error)

CountBuilds gets the count of all builds from the database.

func (*Engine) CountBuildsForDeployment added in v0.27.0

func (e *Engine) CountBuildsForDeployment(ctx context.Context, d *api.Deployment, filters map[string]interface{}) (int64, error)

CountBuildsForDeployment gets the count of builds by deployment URL from the database.

func (*Engine) CountBuildsForOrg added in v0.27.0

func (e *Engine) CountBuildsForOrg(ctx context.Context, org string, filters map[string]interface{}) (int64, error)

CountBuildsForOrg gets the count of builds by org name from the database.

func (*Engine) CountBuildsForRepo added in v0.27.0

func (e *Engine) CountBuildsForRepo(ctx context.Context, r *api.Repo, filters map[string]interface{}, before, after int64) (int64, error)

CountBuildsForRepo gets the count of builds by repo ID from the database.

func (*Engine) CountBuildsForStatus added in v0.27.0

func (e *Engine) CountBuildsForStatus(ctx context.Context, status string, filters map[string]interface{}) (int64, error)

CountBuildsForStatus gets the count of builds by status from the database.

func (*Engine) CreateBuild added in v0.27.0

func (e *Engine) CreateBuild(ctx context.Context, b *api.Build) (*api.Build, error)

CreateBuild creates a new build in the database.

func (*Engine) CreateBuildIndexes added in v0.27.0

func (e *Engine) CreateBuildIndexes(ctx context.Context) error

CreateBuildIndexes creates the indexes for the builds table in the database.

func (*Engine) CreateBuildTable added in v0.27.0

func (e *Engine) CreateBuildTable(ctx context.Context, driver string) error

CreateBuildTable creates the builds table in the database.

func (*Engine) DeleteBuild added in v0.27.0

func (e *Engine) DeleteBuild(ctx context.Context, b *api.Build) error

DeleteBuild deletes an existing build from the database.

func (*Engine) GetBuild added in v0.27.0

func (e *Engine) GetBuild(ctx context.Context, id int64) (*api.Build, error)

GetBuild gets a build by ID from the database.

func (*Engine) GetBuildForRepo added in v0.27.0

func (e *Engine) GetBuildForRepo(ctx context.Context, r *api.Repo, number int64) (*api.Build, error)

GetBuildForRepo gets a build by repo ID and number from the database.

func (*Engine) LastBuildForRepo added in v0.27.0

func (e *Engine) LastBuildForRepo(ctx context.Context, r *api.Repo, branch string) (*api.Build, error)

LastBuildForRepo gets the last build by repo ID and branch from the database.

func (*Engine) ListBuilds added in v0.27.0

func (e *Engine) ListBuilds(ctx context.Context) ([]*api.Build, error)

ListBuilds gets a list of all builds from the database.

func (*Engine) ListBuildsForDashboardRepo added in v0.27.0

func (e *Engine) ListBuildsForDashboardRepo(ctx context.Context, r *api.Repo, branches, events []string) ([]*api.Build, error)

ListBuildsForDashboardRepo gets a list of builds by repo ID from the database.

func (*Engine) ListBuildsForOrg added in v0.27.0

func (e *Engine) ListBuildsForOrg(ctx context.Context, org string, repoFilters, buildFilters map[string]any, page, perPage int) ([]*api.Build, error)

ListBuildsForOrg gets a list of builds by org name from the database.

func (*Engine) ListBuildsForRepo added in v0.27.0

func (e *Engine) ListBuildsForRepo(ctx context.Context, r *api.Repo, filters map[string]interface{}, before, after int64, page, perPage int) ([]*api.Build, error)

ListBuildsForRepo gets a list of builds by repo ID from the database.

func (*Engine) ListPendingAndRunningBuilds added in v0.27.0

func (e *Engine) ListPendingAndRunningBuilds(ctx context.Context, after string) ([]*api.QueueBuild, error)

ListPendingAndRunningBuilds gets a list of all pending and running builds in the provided timeframe from the database.

func (*Engine) ListPendingAndRunningBuildsForRepo added in v0.27.0

func (e *Engine) ListPendingAndRunningBuildsForRepo(ctx context.Context, repo *api.Repo) ([]*api.Build, error)

ListPendingAndRunningBuilds gets a list of all pending and running builds in the provided timeframe from the database.

func (*Engine) ListPendingApprovalBuilds added in v0.27.0

func (e *Engine) ListPendingApprovalBuilds(ctx context.Context, before string) ([]*api.Build, error)

ListPendingAndRunningBuilds gets a list of all pending and running builds in the provided timeframe from the database.

func (*Engine) UpdateBuild added in v0.27.0

func (e *Engine) UpdateBuild(ctx context.Context, b *api.Build) (*api.Build, error)

UpdateBuild updates an existing build in the database.

type EngineOpt

type EngineOpt func(*Engine) error

EngineOpt represents a configuration option to initialize the database engine for Builds.

func WithClient

func WithClient(client *gorm.DB) EngineOpt

WithClient sets the gorm.io/gorm client in the database engine for Builds.

func WithContext added in v0.21.0

func WithContext(ctx context.Context) EngineOpt

WithContext sets the context in the database engine for Builds.

func WithEncryptionKey added in v0.24.0

func WithEncryptionKey(key string) EngineOpt

WithEncryptionKey sets the encryption key in the database engine for Builds.

func WithLogger

func WithLogger(logger *logrus.Entry) EngineOpt

WithLogger sets the github.com/sirupsen/logrus logger in the database engine for Builds.

func WithSkipCreation

func WithSkipCreation(skipCreation bool) EngineOpt

WithSkipCreation sets the skip creation logic in the database engine for Builds.

Jump to

Keyboard shortcuts

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