(now time.Time, workspace codersdk.Workspace)
| 41 | } |
| 42 | |
| 43 | func WorkspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace) WorkspaceListRow { |
| 44 | status := codersdk.WorkspaceDisplayStatus(workspace.LatestBuild.Job.Status, workspace.LatestBuild.Transition) |
| 45 | |
| 46 | lastBuilt := now.UTC().Sub(workspace.LatestBuild.Job.CreatedAt).Truncate(time.Second) |
| 47 | schedRow := scheduleListRowFromWorkspace(now, workspace) |
| 48 | |
| 49 | healthy := "" |
| 50 | if status == "Starting" || status == "Started" { |
| 51 | healthy = strconv.FormatBool(workspace.Health.Healthy) |
| 52 | } |
| 53 | favIco := " " |
| 54 | if workspace.Favorite { |
| 55 | favIco = "★" |
| 56 | } |
| 57 | workspaceName := favIco + " " + workspace.OwnerName + "/" + workspace.Name |
| 58 | return WorkspaceListRow{ |
| 59 | Favorite: workspace.Favorite, |
| 60 | Workspace: workspace, |
| 61 | WorkspaceName: workspaceName, |
| 62 | OrganizationID: workspace.OrganizationID, |
| 63 | OrganizationName: workspace.OrganizationName, |
| 64 | Template: workspace.TemplateName, |
| 65 | Status: status, |
| 66 | Healthy: healthy, |
| 67 | LastBuilt: durationDisplay(lastBuilt), |
| 68 | CurrentVersion: workspace.LatestBuild.TemplateVersionName, |
| 69 | Outdated: workspace.Outdated, |
| 70 | StartsAt: schedRow.StartsAt, |
| 71 | StartsNext: schedRow.StartsNext, |
| 72 | StopsAfter: schedRow.StopsAfter, |
| 73 | StopsNext: schedRow.StopsNext, |
| 74 | DailyCost: strconv.Itoa(int(workspace.LatestBuild.DailyCost)), |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func (r *RootCmd) list() *serpent.Command { |
| 79 | var ( |
no test coverage detected