MCPcopy Index your code
hub / github.com/coder/coder / getWorkspaceTask

Method getWorkspaceTask

coderd/wsbuilder/wsbuilder.go:695–712  ·  view source on GitHub ↗

getWorkspaceTask returns the task associated with the workspace, if any. If no task exists, it returns (nil, nil).

(store database.Store)

Source from the content-addressed store, hash-verified

693// getWorkspaceTask returns the task associated with the workspace, if any.
694// If no task exists, it returns (nil, nil).
695func (b *Builder) getWorkspaceTask(store database.Store) (*database.Task, error) {
696 if b.hasTask != nil {
697 return b.task, nil
698 }
699 t, err := store.GetTaskByWorkspaceID(b.ctx, b.workspace.ID)
700 if err != nil {
701 if xerrors.Is(err, sql.ErrNoRows) {
702 b.hasTask = ptr.Ref(false)
703 //nolint:nilnil // No task exists.
704 return nil, nil
705 }
706 return nil, xerrors.Errorf("get task: %w", err)
707 }
708
709 b.task = &t
710 b.hasTask = ptr.Ref(true)
711 return b.task, nil
712}
713
714func (b *Builder) getTemplateTerraformValues() (*database.TemplateVersionTerraformValue, error) {
715 if b.terraformValues != nil {

Callers 2

buildTxMethod · 0.95
checkUsageMethod · 0.95

Calls 4

RefFunction · 0.92
GetTaskByWorkspaceIDMethod · 0.65
IsMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected