From f6a5398bf9bcce1efe268655e72789d644a240ae Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Fri, 26 May 2023 22:59:28 +0000 Subject: [PATCH] Update fields to show --- internal/codespaces/api/api.go | 3 +++ pkg/cmd/codespace/view.go | 20 ++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/internal/codespaces/api/api.go b/internal/codespaces/api/api.go index 8fdf4f1d3..e9388d5ed 100644 --- a/internal/codespaces/api/api.go +++ b/internal/codespaces/api/api.go @@ -269,6 +269,7 @@ var ViewCodespaceFields = []string{ "createdAt", "lastUsedAt", "idleTimeoutMinutes", + "retentionPeriodDays", "retentionExpiresAt", "recentFolders", } @@ -287,6 +288,8 @@ func (c *Codespace) ExportData(fields []string) map[string]interface{} { data[f] = c.Machine.Name case "machineDisplayName": data[f] = c.Machine.DisplayName + case "retentionPeriodDays": + data[f] = c.RetentionPeriodMinutes / 1440 case "gitStatus": data[f] = map[string]interface{}{ "ref": c.GitStatus.Ref, diff --git a/pkg/cmd/codespace/view.go b/pkg/cmd/codespace/view.go index 28d490251..e923c92b4 100644 --- a/pkg/cmd/codespace/view.go +++ b/pkg/cmd/codespace/view.go @@ -35,7 +35,8 @@ func newViewCmd(app *App) *cobra.Command { } func (a *App) ViewCodespace(ctx context.Context, opts *viewOptions, exporter cmdutil.Exporter) error { - if codespaceName := os.Getenv("CODESPACES_NAME"); os.Getenv("CODESPACES") == "true" && codespaceName != "" { + // If we are in a codespace, show the details for it + if codespaceName := os.Getenv("CODESPACE_NAME"); os.Getenv("CODESPACES") == "true" && codespaceName != "" { opts.selector.codespaceName = codespaceName } @@ -66,21 +67,12 @@ func (a *App) ViewCodespace(ctx context.Context, opts *viewOptions, exporter cmd {"Name", formattedName}, {"Display Name", c.DisplayName}, {"State", c.State}, - {"Machine Name", c.Machine.Name}, - {"Machine Display Name", c.Machine.DisplayName}, - {"Prebuild", strconv.FormatBool(c.Prebuild)}, - {"Owner", c.Owner.Login}, - {"BillableOwner", c.BillableOwner.Login}, - {"Location", c.Location}, - {"Repository", c.Repository.FullName}, - {"Branch", c.GitStatus.Ref}, - {"Devcontainer Path", c.DevContainerPath}, {"Git Status", formatGitStatus(c)}, + {"Devcontainer Path", c.DevContainerPath}, + {"Machine Display Name", c.Machine.DisplayName}, {"Created At", c.CreatedAt}, - {"Last Used At", c.LastUsedAt}, - {"Idle Timeout Minutes", strconv.Itoa(c.IdleTimeoutMinutes)}, - {"Retention Period Days", strconv.Itoa(c.RetentionPeriodMinutes / 1440)}, - {"Retention Expires At", c.RetentionExpiresAt}, + {"Idle Timeout", strconv.Itoa(c.IdleTimeoutMinutes) + " minutes"}, + {"Retention Period", strconv.Itoa(c.RetentionPeriodMinutes/1440) + " days"}, } for _, field := range fields {