Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cli/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (r *RootCmd) create() *clibase.Cmd {
workspaceName string

parameterFlags workspaceParameterFlags
autoUpdates string
)
client := new(codersdk.Client)
cmd := &clibase.Cmd{
Expand Down Expand Up @@ -169,6 +170,7 @@ func (r *RootCmd) create() *clibase.Cmd {
AutostartSchedule: schedSpec,
TTLMillis: ttlMillis,
RichParameterValues: richParameters,
AutomaticUpdates: codersdk.AutomaticUpdates(autoUpdates),
})
if err != nil {
return xerrors.Errorf("create workspace: %w", err)
Expand Down Expand Up @@ -208,6 +210,13 @@ func (r *RootCmd) create() *clibase.Cmd {
Description: "Specify a duration after which the workspace should shut down (e.g. 8h).",
Value: clibase.DurationOf(&stopAfter),
},
clibase.Option{
Flag: "automatic-updates",
Env: "CODER_WORKSPACE_AUTOMATIC_UPDATES",
Description: "Specify automatic updates setting for the workspace (accepts 'always' or 'never').",
Default: string(codersdk.AutomaticUpdatesNever),
Value: clibase.StringOf(&autoUpdates),
},
cliui.SkipPromptOption(),
)
cmd.Options = append(cmd.Options, parameterFlags.cliParameters()...)
Expand Down
2 changes: 2 additions & 0 deletions cli/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestCreate(t *testing.T) {
"--template", template.Name,
"--start-at", "9:30AM Mon-Fri US/Central",
"--stop-after", "8h",
"--automatic-updates", "always",
}
inv, root := clitest.New(t, args...)
clitest.SetupConfig(t, client, root)
Expand Down Expand Up @@ -73,6 +74,7 @@ func TestCreate(t *testing.T) {
if assert.NotNil(t, ws.TTLMillis) {
assert.Equal(t, *ws.TTLMillis, 8*time.Hour.Milliseconds())
}
assert.Equal(t, codersdk.AutomaticUpdatesAlways, ws.AutomaticUpdates)
}
})

Expand Down
4 changes: 4 additions & 0 deletions cli/testdata/coder_create_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ USAGE:
$ coder create <username>/<workspace_name>

OPTIONS:
--automatic-updates string, $CODER_WORKSPACE_AUTOMATIC_UPDATES (default: never)
Specify automatic updates setting for the workspace (accepts 'always'
or 'never').

--parameter string-array, $CODER_RICH_PARAMETER
Rich parameter value in the format "name=value".

Expand Down
3 changes: 2 additions & 1 deletion cli/testdata/coder_list_--output_json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"health": {
"healthy": true,
"failing_agents": []
}
},
"automatic_updates": "never"
}
]
74 changes: 74 additions & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions coderd/autobuild/lifecycle_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ func (e *Executor) runOnce(t time.Time) Stats {
SetLastWorkspaceBuildInTx(&latestBuild).
SetLastWorkspaceBuildJobInTx(&latestJob).
Reason(reason)
log.Debug(e.ctx, "auto building workspace", slog.F("transition", nextTransition))
if nextTransition == database.WorkspaceTransitionStart &&
ws.AutomaticUpdates == database.AutomaticUpdatesAlways {
log.Debug(e.ctx, "autostarting with active version")
builder = builder.ActiveVersion()
}

build, job, err = builder.Build(e.ctx, tx, nil)
if err != nil {
Expand Down
Loading