Skip to content

Commit 4bb513e

Browse files
committed
feat(cli): add daily_cost to coder ls
1 parent be40dc8 commit 4bb513e

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

cli/list.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type workspaceListRow struct {
3030
Outdated bool `json:"-" table:"outdated"`
3131
StartsAt string `json:"-" table:"starts at"`
3232
StopsAfter string `json:"-" table:"stops after"`
33+
DailyCost string `json:"-" table:"daily cost"`
3334
}
3435

3536
func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]codersdk.User, workspace codersdk.Workspace) workspaceListRow {
@@ -68,6 +69,7 @@ func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]coders
6869
Outdated: workspace.Outdated,
6970
StartsAt: autostartDisplay,
7071
StopsAfter: autostopDisplay,
72+
DailyCost: strconv.Itoa(int(workspace.LatestBuild.DailyCost)),
7173
}
7274
}
7375

@@ -78,7 +80,19 @@ func (r *RootCmd) list() *clibase.Cmd {
7880
searchQuery string
7981
displayWorkspaces []workspaceListRow
8082
formatter = cliui.NewOutputFormatter(
81-
cliui.TableFormat([]workspaceListRow{}, nil),
83+
cliui.TableFormat(
84+
[]workspaceListRow{},
85+
[]string{
86+
"workspace",
87+
"template",
88+
"status",
89+
"healthy",
90+
"last built",
91+
"outdated",
92+
"starts at",
93+
"stops after",
94+
},
95+
),
8296
cliui.JSONFormat(),
8397
)
8498
)

provisionerd/provisionerd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ func (p *Server) acquireJob(ctx context.Context) {
404404
runner.Options{
405405
Updater: p,
406406
QuotaCommitter: p,
407-
Logger: p.opts.Logger,
407+
Logger: p.opts.Logger.Named("runner"),
408408
Filesystem: p.opts.Filesystem,
409409
WorkDirectory: p.opts.WorkDirectory,
410410
Provisioner: provisioner,

provisionerd/runner/runner.go

+3
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,9 @@ func (r *Runner) buildWorkspace(ctx context.Context, stage string, req *sdkproto
964964
}
965965

966966
func (r *Runner) commitQuota(ctx context.Context, resources []*sdkproto.Resource) *proto.FailedJob {
967+
r.logger.Debug(ctx, "committing quota",
968+
slog.F("resources", resources),
969+
)
967970
cost := sumDailyCost(resources)
968971
if cost == 0 {
969972
return nil

0 commit comments

Comments
 (0)