Skip to content

Commit ece35cf

Browse files
committed
Merge branch 'main' into icons-page
2 parents 79ef7a8 + 71ad590 commit ece35cf

File tree

92 files changed

+2152
-729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2152
-729
lines changed

cli/create.go

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func (r *RootCmd) create() *clibase.Cmd {
2727
workspaceName string
2828

2929
parameterFlags workspaceParameterFlags
30+
autoUpdates string
3031
)
3132
client := new(codersdk.Client)
3233
cmd := &clibase.Cmd{
@@ -169,6 +170,7 @@ func (r *RootCmd) create() *clibase.Cmd {
169170
AutostartSchedule: schedSpec,
170171
TTLMillis: ttlMillis,
171172
RichParameterValues: richParameters,
173+
AutomaticUpdates: codersdk.AutomaticUpdates(autoUpdates),
172174
})
173175
if err != nil {
174176
return xerrors.Errorf("create workspace: %w", err)
@@ -208,6 +210,13 @@ func (r *RootCmd) create() *clibase.Cmd {
208210
Description: "Specify a duration after which the workspace should shut down (e.g. 8h).",
209211
Value: clibase.DurationOf(&stopAfter),
210212
},
213+
clibase.Option{
214+
Flag: "automatic-updates",
215+
Env: "CODER_WORKSPACE_AUTOMATIC_UPDATES",
216+
Description: "Specify automatic updates setting for the workspace (accepts 'always' or 'never').",
217+
Default: string(codersdk.AutomaticUpdatesNever),
218+
Value: clibase.StringOf(&autoUpdates),
219+
},
211220
cliui.SkipPromptOption(),
212221
)
213222
cmd.Options = append(cmd.Options, parameterFlags.cliParameters()...)

cli/create_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func TestCreate(t *testing.T) {
3838
"--template", template.Name,
3939
"--start-at", "9:30AM Mon-Fri US/Central",
4040
"--stop-after", "8h",
41+
"--automatic-updates", "always",
4142
}
4243
inv, root := clitest.New(t, args...)
4344
clitest.SetupConfig(t, client, root)
@@ -73,6 +74,7 @@ func TestCreate(t *testing.T) {
7374
if assert.NotNil(t, ws.TTLMillis) {
7475
assert.Equal(t, *ws.TTLMillis, 8*time.Hour.Milliseconds())
7576
}
77+
assert.Equal(t, codersdk.AutomaticUpdatesAlways, ws.AutomaticUpdates)
7678
}
7779
})
7880

cli/testdata/coder_create_--help.golden

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ USAGE:
1010
$ coder create <username>/<workspace_name>
1111

1212
OPTIONS:
13+
--automatic-updates string, $CODER_WORKSPACE_AUTOMATIC_UPDATES (default: never)
14+
Specify automatic updates setting for the workspace (accepts 'always'
15+
or 'never').
16+
1317
--parameter string-array, $CODER_RICH_PARAMETER
1418
Rich parameter value in the format "name=value".
1519

cli/testdata/coder_list_--output_json.golden

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"health": {
5858
"healthy": true,
5959
"failing_agents": []
60-
}
60+
},
61+
"automatic_updates": "never"
6162
}
6263
]

coderd/apidoc/docs.go

+78-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+65-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/autobuild/lifecycle_executor.go

+6
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ func (e *Executor) runOnce(t time.Time) Stats {
177177
SetLastWorkspaceBuildInTx(&latestBuild).
178178
SetLastWorkspaceBuildJobInTx(&latestJob).
179179
Reason(reason)
180+
log.Debug(e.ctx, "auto building workspace", slog.F("transition", nextTransition))
181+
if nextTransition == database.WorkspaceTransitionStart &&
182+
ws.AutomaticUpdates == database.AutomaticUpdatesAlways {
183+
log.Debug(e.ctx, "autostarting with active version")
184+
builder = builder.ActiveVersion()
185+
}
180186

181187
build, job, err = builder.Build(e.ctx, tx, nil)
182188
if err != nil {

0 commit comments

Comments
 (0)