Add provision job metadata to identify prebuilds

Signed-off-by: Danny Kopping <danny@coder.com>
This commit is contained in:
Danny Kopping
2025-01-28 09:20:08 +00:00
parent b7c43f663e
commit a59a03d5f4
7 changed files with 23 additions and 1 deletions

View File

@ -72,6 +72,7 @@ type Builder struct {
lastBuildJob *database.ProvisionerJob
parameterNames *[]string
parameterValues *[]string
prebuild bool
verifyNoLegacyParametersOnce bool
}
@ -168,6 +169,12 @@ func (b Builder) RichParameterValues(p []codersdk.WorkspaceBuildParameter) Build
return b
}
func (b Builder) MarkPrebuild() Builder {
// nolint: revive
b.prebuild = true
return b
}
// 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.
@ -295,6 +302,7 @@ func (b *Builder) buildTx(authFunc func(action policy.Action, object rbac.Object
input, err := json.Marshal(provisionerdserver.WorkspaceProvisionJob{
WorkspaceBuildID: workspaceBuildID,
LogLevel: b.logLevel,
IsPrebuild: b.prebuild,
})
if err != nil {
return nil, nil, nil, BuildError{