Skip to content

Commit 26859f8

Browse files
authored
Adds BUILD and SHELL columns to ls output (#225)
* Adds `BUILD` and `SHELL` columns to `ls` output * Change helper function name to better reflect column * Fix CI * Update upload-artifact to v4
1 parent d01086b commit 26859f8

7 files changed

Lines changed: 27 additions & 30 deletions

File tree

.github/workflows/fmt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828

2929
- name: install
30-
run: make install
30+
run: make install-tools
3131
- name: check fmt
3232
run: make fmtcheck
3333
# - name: Report Status

.github/workflows/legacy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ jobs:
2727
- name: Build
2828
run: make ci
2929
- name: Upload coverage
30-
uses: actions/upload-artifact@v3
30+
uses: actions/upload-artifact@v4
3131
with:
3232
name: coverage
3333
path: coverage.*
3434

3535
- name: Upload dist
36-
uses: actions/upload-artifact@v3
36+
uses: actions/upload-artifact@v4
3737
with:
3838
name: dist
3939
path: dist

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
go-version: '1.22.6'
2626
cache: true
2727
- name: install
28-
run: make install
28+
run: make install-tools
2929
- name: lint
3030
run: make lint
3131
# - name: Report Status

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ jobs:
2525
go-version: '1.22.6'
2626
cache: true
2727
- name: install
28-
run: make install
28+
run: make install-tools
2929
- name: test
3030
run: make test
3131
- name: Upload coverage
32-
uses: actions/upload-artifact@v3
32+
uses: actions/upload-artifact@v4
3333
with:
3434
name: coverage
3535
path: coverage.*
3636

3737
- name: Upload dist
38-
uses: actions/upload-artifact@v3
38+
uses: actions/upload-artifact@v4
3939
with:
4040
name: dist
4141
path: dist

.github/workflows/vet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
go-version: '1.22.6'
2626
cache: true
2727
- name: install
28-
run: make install
28+
run: make install-tools
2929
- name: vet
3030
run: make vet
3131
# - name: Report Status

pkg/cmd/ls/ls.go

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,6 @@ func (ls Ls) displayWorkspacesAndHelp(org *entity.Organization, otherOrgs []enti
325325

326326
displayLsResetBreadCrumb(ls.terminal, userWorkspaces)
327327
// displayLsConnectBreadCrumb(ls.terminal, userWorkspaces)
328-
329-
// if !enableSSHCol {
330-
// ls.terminal.Vprintf(ls.terminal.Green("Or ssh:\n"))
331-
// for _, v := range userWorkspaces {
332-
// if v.Status == entity.Running {
333-
// ls.terminal.Vprintf(ls.terminal.Yellow("\tssh %s\n", v.GetLocalIdentifier()))
334-
// }
335-
// }
336-
// }
337328
}
338329
}
339330

@@ -405,8 +396,6 @@ func displayProjects(t *terminal.Terminal, orgName string, projects []virtualpro
405396
}
406397
}
407398

408-
const enableSSHCol = false
409-
410399
func getBrevTableOptions() table.Options {
411400
options := table.OptionsDefault
412401
options.DrawBorder = false
@@ -420,10 +409,7 @@ func displayWorkspacesTable(t *terminal.Terminal, workspaces []entity.Workspace,
420409
ta := table.NewWriter()
421410
ta.SetOutputMirror(os.Stdout)
422411
ta.Style().Options = getBrevTableOptions()
423-
header := table.Row{"Name", "Status", "ID", "Machine"}
424-
if enableSSHCol {
425-
header = table.Row{"Name", "Status", "SSH", "ID", "Machine"}
426-
}
412+
header := table.Row{"Name", "Status", "Build", "Shell", "ID", "Machine"}
427413
ta.AppendHeader(header)
428414
for _, w := range workspaces {
429415
isShared := ""
@@ -432,15 +418,20 @@ func displayWorkspacesTable(t *terminal.Terminal, workspaces []entity.Workspace,
432418
}
433419
status := getWorkspaceDisplayStatus(w)
434420
instanceString := utilities.GetInstanceString(w)
435-
workspaceRow := []table.Row{{fmt.Sprintf("%s %s", w.Name, isShared), getStatusColoredText(t, status), w.ID, instanceString}}
436-
if enableSSHCol {
437-
workspaceRow = []table.Row{{w.Name, getStatusColoredText(t, status), w.GetLocalIdentifier(), w.ID, instanceString}}
438-
}
421+
workspaceRow := []table.Row{{fmt.Sprintf("%s %s", w.Name, isShared), getStatusColoredText(t, status), getStatusColoredText(t, string(w.VerbBuildStatus)), getStatusColoredText(t, getShellDisplayStatus(w)), w.ID, instanceString}}
439422
ta.AppendRows(workspaceRow)
440423
}
441424
ta.Render()
442425
}
443426

427+
func getShellDisplayStatus(w entity.Workspace) string {
428+
status := entity.NotReady
429+
if w.Status == entity.Running && w.VerbBuildStatus == entity.Completed {
430+
status = entity.Ready
431+
}
432+
return status
433+
}
434+
444435
func getWorkspaceDisplayStatus(w entity.Workspace) string {
445436
status := w.Status
446437
if w.Status == entity.Running && w.HealthStatus == entity.Unhealthy {
@@ -480,11 +471,11 @@ func displayProjectsTable(projects []virtualproject.VirtualProject) {
480471

481472
func getStatusColoredText(t *terminal.Terminal, status string) string {
482473
switch status {
483-
case entity.Running:
474+
case entity.Running, entity.Ready, string(entity.Completed):
484475
return t.Green(status)
485-
case entity.Starting, entity.Deploying, entity.Stopping:
476+
case entity.Starting, entity.Deploying, entity.Stopping, string(entity.Building), string(entity.Pending):
486477
return t.Yellow(status)
487-
case entity.Failure, entity.Deleting, entity.Unhealthy:
478+
case entity.Failure, entity.Deleting, entity.Unhealthy, string(entity.CreateFailed):
488479
return t.Red(status)
489480
default:
490481
return status

pkg/entity/entity.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ const (
259259
Unavailable = "UNAVAILABLE"
260260
)
261261

262+
// Shell Status
263+
const (
264+
NotReady = "NOT READY"
265+
Ready = "READY"
266+
)
267+
262268
type WorkspaceGroup struct {
263269
ID string `json:"id"`
264270
Name string `json:"name"`

0 commit comments

Comments
 (0)