wsbuilder

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package wsbuilder provides the Builder object, which encapsulates the common business logic of inserting a new workspace build into the database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildError

type BuildError struct {
	// Status is a suitable HTTP status code
	Status  int
	Message string
	Wrapped error
}

func (BuildError) Error

func (e BuildError) Error() string

func (BuildError) Unwrap

func (e BuildError) Unwrap() error

type Builder

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

Builder encapsulates the business logic of inserting a new workspace build into the database.

Builder follows the so-called "Builder" pattern where options that customize the kind of build you get return a new instance of the Builder with the option applied.

Example:

b = wsbuilder.New(workspace, transition).VersionID(vID).Initiator(me) build, job, err := b.Build(...)

func (Builder) ActiveVersion

func (b Builder) ActiveVersion() Builder

func (*Builder) Build

func (b *Builder) Build(
	ctx context.Context,
	store database.Store,
	authFunc func(action rbac.Action, object rbac.Objecter) bool,
) (
	*database.WorkspaceBuild, *database.ProvisionerJob, error,
)

Build computes and inserts a new workspace build into the database. If authFunc is provided, it also performs authorization preflight checks.

func (Builder) DeploymentValues added in v0.25.0

func (b Builder) DeploymentValues(dv *codersdk.DeploymentValues) Builder

func (Builder) Initiator

func (b Builder) Initiator(u uuid.UUID) Builder

func (Builder) LogLevel

func (b Builder) LogLevel(l string) Builder

func (Builder) Orphan

func (b Builder) Orphan() Builder

func (Builder) Reason

func (b Builder) Reason(r database.BuildReason) Builder

func (Builder) RichParameterValues

func (b Builder) RichParameterValues(p []codersdk.WorkspaceBuildParameter) Builder

func (Builder) SetLastWorkspaceBuildInTx

func (b Builder) SetLastWorkspaceBuildInTx(build *database.WorkspaceBuild) Builder

SetLastWorkspaceBuildInTx prepopulates the Builder's cache with the last workspace build. This allows us to avoid a repeated database query when the Builder's caller also needs the workspace build, e.g. auto-start & auto-stop.

CAUTION: only call this method from within a database transaction with RepeatableRead isolation. This transaction MUST be the database.Store you call Build() with.

func (Builder) SetLastWorkspaceBuildJobInTx

func (b Builder) SetLastWorkspaceBuildJobInTx(job *database.ProvisionerJob) Builder

SetLastWorkspaceBuildJobInTx prepopulates the Builder's cache with the last workspace build job. This allows us to avoid a repeated database query when the Builder's caller also needs the workspace build job, e.g. auto-start & auto-stop.

CAUTION: only call this method from within a database transaction with RepeatableRead isolation. This transaction MUST be the database.Store you call Build() with.

func (Builder) State

func (b Builder) State(state []byte) Builder

func (Builder) VersionID

func (b Builder) VersionID(v uuid.UUID) Builder

type Option

type Option func(Builder) Builder

Jump to

Keyboard shortcuts

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