Skip to content

Commit bbd8288

Browse files
committed
address PR comments
1 parent a763d2f commit bbd8288

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

cli/bump.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ func bump() *cobra.Command {
5858

5959
_, _ = fmt.Fprintf(
6060
cmd.OutOrStdout(),
61-
"Workspace %q will now stop at %s\n", workspace.Name,
62-
newDeadline.Format(time.RFC822),
61+
"Workspace %q will now stop at %s on %s\n", workspace.Name,
62+
newDeadline.Format(timeFormat),
63+
newDeadline.Format(dateFormat),
6364
)
6465

6566
return nil

cli/constants.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package cli
2+
3+
const (
4+
timeFormat = "3:04:05 PM MST"
5+
dateFormat = "Jan 2, 2006"
6+
)

cli/ttl.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ func ttlset() *cobra.Command {
111111
nextShutdown := sched.Next(time.Now()).Add(truncated).In(sched.Location())
112112
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%q will shut down at %s on %s (%s after start).\n",
113113
workspace.Name,
114-
nextShutdown.Format("15:04:05 MST"),
115-
nextShutdown.Format("2006-02-01"),
114+
nextShutdown.Format(timeFormat),
115+
nextShutdown.Format(dateFormat),
116116
truncated,
117117
)
118+
119+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "NOTE: this will only take effect the next time the workspace is started.\n")
118120
return nil
119121
},
120122
}

coderd/workspaces.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929
"github.com/coder/coder/codersdk"
3030
)
3131

32+
const workspaceDefaultTTL = 12 * time.Hour
33+
3234
func (api *API) workspace(rw http.ResponseWriter, r *http.Request) {
3335
workspace := httpmw.WorkspaceParam(r)
3436
if !api.Authorize(rw, r, rbac.ActionRead, workspace) {
@@ -320,7 +322,7 @@ func (api *API) postWorkspacesByOrganization(rw http.ResponseWriter, r *http.Req
320322

321323
if !dbTTL.Valid {
322324
// Default to min(12 hours, template maximum). Just defaulting to template maximum can be surprising.
323-
dbTTL = sql.NullInt64{Valid: true, Int64: min(template.MaxTtl, int64(12*time.Hour))}
325+
dbTTL = sql.NullInt64{Valid: true, Int64: min(template.MaxTtl, int64(workspaceDefaultTTL))}
324326
}
325327

326328
workspace, err := api.Database.GetWorkspaceByOwnerIDAndName(r.Context(), database.GetWorkspaceByOwnerIDAndNameParams{

0 commit comments

Comments
 (0)