Documentation
¶
Overview ¶
Package wsbuilder provides the Builder object, which encapsulates the common business logic of inserting a new workspace build into the database.
Index ¶
- type BuildError
- type Builder
- func (b Builder) ActiveVersion() Builder
- func (b *Builder) Build(ctx context.Context, store database.Store, ...) (*database.WorkspaceBuild, *database.ProvisionerJob, error)
- func (b Builder) DeploymentValues(dv *codersdk.DeploymentValues) Builder
- func (b Builder) Initiator(u uuid.UUID) Builder
- func (b Builder) LogLevel(l string) Builder
- func (b Builder) Orphan() Builder
- func (b Builder) Reason(r database.BuildReason) Builder
- func (b Builder) RichParameterValues(p []codersdk.WorkspaceBuildParameter) Builder
- func (b Builder) SetLastWorkspaceBuildInTx(build *database.WorkspaceBuild) Builder
- func (b Builder) SetLastWorkspaceBuildJobInTx(job *database.ProvisionerJob) Builder
- func (b Builder) State(state []byte) Builder
- func (b Builder) VersionID(v uuid.UUID) Builder
- type Option
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 (*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) 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.