WorkspaceDisplayStatus computes a status to display on CLI/UI based on the workspace transition and the status of the provisioner job. This code is in sync with how we compute the status on frontend. Ref: site/src/util/workspace.ts (getWorkspaceStatus)
(jobStatus ProvisionerJobStatus, transition WorkspaceTransition)
| 21 | // This code is in sync with how we compute the status on frontend. |
| 22 | // Ref: site/src/util/workspace.ts (getWorkspaceStatus) |
| 23 | func WorkspaceDisplayStatus(jobStatus ProvisionerJobStatus, transition WorkspaceTransition) string { |
| 24 | switch jobStatus { |
| 25 | case ProvisionerJobSucceeded: |
| 26 | status, ok := succeededStatusFromTransition[transition] |
| 27 | if !ok { |
| 28 | return unknownStatus |
| 29 | } |
| 30 | return status |
| 31 | case ProvisionerJobRunning: |
| 32 | status, ok := runningStatusFromTransition[transition] |
| 33 | if !ok { |
| 34 | return unknownStatus |
| 35 | } |
| 36 | return status |
| 37 | case ProvisionerJobPending: |
| 38 | return "Queued" |
| 39 | case ProvisionerJobCanceling: |
| 40 | return "Canceling" |
| 41 | case ProvisionerJobCanceled: |
| 42 | return "Canceled" |
| 43 | case ProvisionerJobFailed: |
| 44 | return "Failed" |
| 45 | default: |
| 46 | return unknownStatus |
| 47 | } |
| 48 | } |
no outgoing calls