Skip to content

Commit 939938e

Browse files
committed
Merge remote-tracking branch 'origin/main' into cj/workspaces-last-used-at-timestamptz
2 parents 19663d7 + 5de5d20 commit 939938e

File tree

44 files changed

+1126
-340
lines changed

Some content is hidden

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

44 files changed

+1126
-340
lines changed

.github/actions/upload-datadog/action.yaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Upload tests to datadog
1+
name: Upload tests to Datadog
22
if: always()
33
inputs:
44
api-key:
@@ -7,8 +7,26 @@ inputs:
77
runs:
88
using: "composite"
99
steps:
10+
- name: Set work dir
11+
shell: bash
12+
run: |
13+
WORK_DIR=${{ runner.temp }}/datadog-ci
14+
mkdir -p $WORK_DIR
15+
echo "WORK_DIR=$WORK_DIR" >> $GITHUB_ENV
16+
# The npm install was taking 30s to 1m, accounting for 20+% of the total
17+
# job time.
18+
- name: Cache datadog-ci
19+
uses: buildjet/cache@v3
20+
with:
21+
path: |
22+
${{ env.WORK_DIR }}
23+
key: datadog-ci-${{ runner.os }}
24+
restore-keys: |
25+
datadog-ci-${{ runner.os }}-
26+
datadog-ci-
1027
- shell: bash
1128
run: |
29+
cd ${{ env.WORK_DIR }}
1230
owner=${{ github.repository_owner }}
1331
echo "owner: $owner"
1432
if [[ $owner != "coder" ]]; then
@@ -20,8 +38,8 @@ runs:
2038
echo "No API key provided, skipping..."
2139
exit 0
2240
fi
23-
npm install -g @datadog/datadog-ci@2.10.0
24-
datadog-ci junit upload --service coder ./gotests.xml \
41+
npm install @datadog/datadog-ci@2.10.0
42+
npm x -- datadog-ci junit upload --service coder ./gotests.xml \
2543
--tags os:${{runner.os}} --tags runner_name:${{runner.name}}
2644
env:
2745
DATADOG_API_KEY: ${{ inputs.api-key }}

cli/testdata/coder_templates_init_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ USAGE:
66
Get started with a templated template.
77

88
OPTIONS:
9-
--id aws-ecs-container|aws-linux|aws-windows|azure-linux|do-linux|docker|docker-with-dotfiles|fly-docker-image|gcp-linux|gcp-vm-container|gcp-windows|kubernetes
9+
--id aws-ecs-container|aws-linux|aws-windows|azure-linux|do-linux|docker|docker-with-dotfiles|gcp-linux|gcp-vm-container|gcp-windows|kubernetes
1010
Specify a given example template by ID.
1111

1212
———

coderd/schedule/cron/cron.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ func (s Schedule) Min() time.Duration {
173173
return durMin
174174
}
175175

176+
// TimeParsed returns the parsed time.Time of the minute and hour fields. If the
177+
// time cannot be represented in a valid time.Time, a zero time is returned.
178+
func (s Schedule) TimeParsed() time.Time {
179+
minute := strings.Fields(s.cronStr)[0]
180+
hour := strings.Fields(s.cronStr)[1]
181+
maybeTime := fmt.Sprintf("%s:%s", hour, minute)
182+
t, err := time.ParseInLocation("15:4", maybeTime, s.sched.Location)
183+
if err != nil {
184+
return time.Time{}
185+
}
186+
return t
187+
}
188+
176189
// Time returns a humanized form of the minute and hour fields.
177190
func (s Schedule) Time() string {
178191
minute := strings.Fields(s.cronStr)[0]

codersdk/deployment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var FeatureNames = []FeatureName{
6464
FeatureExternalProvisionerDaemons,
6565
FeatureAppearance,
6666
FeatureAdvancedTemplateScheduling,
67+
FeatureTemplateAutostopRequirement,
6768
FeatureWorkspaceProxy,
6869
FeatureUserRoleManagement,
6970
FeatureExternalTokenEncryption,

docs/cli/templates_init.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/images/display-apps.png

25.1 KB
Loading

docs/templates/index.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,29 @@ By default, all templates allow developers to connect over SSH and a web
411411
terminal. See [Configuring Web IDEs](../ides/web-ides.md) to learn how to give
412412
users access to additional web applications.
413413

414+
Template administrators can hide apps like the web-based Terminal or VS Code
415+
Desktop with the
416+
[`display_apps`](https://registry.terraform.io/providers/coder/coder/0.11.2/docs/resources/agent#display_apps)
417+
configuration in the
418+
[`coder_agent`](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent)
419+
resource. For example, the following configuration block will hide all default
420+
Coder apps except the web terminal.
421+
422+
```hcl
423+
display_apps {
424+
vscode = false
425+
vscode_insiders = false
426+
ssh_helper = false
427+
port_forwarding_helper = false
428+
web_terminal = true
429+
}
430+
```
431+
432+
Example use cases for `display_apps` are JetBrains users or zero-trust
433+
deployments who do not want nor should have access to a local VS Code IDE.
434+
435+
![display-apps](../images/display-apps.png)
436+
414437
### Data source
415438

416439
When a workspace is being started or stopped, the `coder_workspace` data source

enterprise/coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
472472
codersdk.FeatureAdvancedTemplateScheduling: true,
473473
// FeatureTemplateAutostopRequirement depends on
474474
// FeatureAdvancedTemplateScheduling.
475-
codersdk.FeatureTemplateAutostopRequirement: api.DefaultQuietHoursSchedule != "",
475+
codersdk.FeatureTemplateAutostopRequirement: api.AGPL.Experiments.Enabled(codersdk.ExperimentTemplateAutostopRequirement) && api.DefaultQuietHoursSchedule != "",
476476
codersdk.FeatureWorkspaceProxy: true,
477477
codersdk.FeatureUserRoleManagement: true,
478478
})

enterprise/coderd/users.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (api *API) userQuietHoursSchedule(rw http.ResponseWriter, r *http.Request)
6868
httpapi.Write(ctx, rw, http.StatusOK, codersdk.UserQuietHoursScheduleResponse{
6969
RawSchedule: opts.Schedule.String(),
7070
UserSet: opts.UserSet,
71-
Time: opts.Schedule.Time(),
71+
Time: opts.Schedule.TimeParsed().Format("15:40"),
7272
Timezone: opts.Schedule.Location().String(),
7373
Next: opts.Schedule.Next(time.Now().In(opts.Schedule.Location())),
7474
})
@@ -114,7 +114,7 @@ func (api *API) putUserQuietHoursSchedule(rw http.ResponseWriter, r *http.Reques
114114
httpapi.Write(ctx, rw, http.StatusOK, codersdk.UserQuietHoursScheduleResponse{
115115
RawSchedule: opts.Schedule.String(),
116116
UserSet: opts.UserSet,
117-
Time: opts.Schedule.Time(),
117+
Time: opts.Schedule.TimeParsed().Format("15:40"),
118118
Timezone: opts.Schedule.Location().String(),
119119
Next: opts.Schedule.Next(time.Now().In(opts.Schedule.Location())),
120120
})

enterprise/coderd/users_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ func TestUserQuietHours(t *testing.T) {
2121
t.Run("OK", func(t *testing.T) {
2222
t.Parallel()
2323

24-
defaultQuietHoursSchedule := "CRON_TZ=America/Chicago 0 0 * * *"
24+
defaultQuietHoursSchedule := "CRON_TZ=America/Chicago 0 1 * * *"
2525
defaultScheduleParsed, err := cron.Daily(defaultQuietHoursSchedule)
2626
require.NoError(t, err)
2727
nextTime := defaultScheduleParsed.Next(time.Now().In(defaultScheduleParsed.Location()))
2828
if time.Until(nextTime) < time.Hour {
2929
// Use a different default schedule instead, because we want to avoid
3030
// the schedule "ticking over" during this test run.
31-
defaultQuietHoursSchedule = "CRON_TZ=America/Chicago 0 12 * * *"
31+
defaultQuietHoursSchedule = "CRON_TZ=America/Chicago 0 13 * * *"
3232
defaultScheduleParsed, err = cron.Daily(defaultQuietHoursSchedule)
3333
require.NoError(t, err)
3434
}
@@ -55,7 +55,7 @@ func TestUserQuietHours(t *testing.T) {
5555
require.NoError(t, err)
5656
require.Equal(t, defaultScheduleParsed.String(), sched1.RawSchedule)
5757
require.False(t, sched1.UserSet)
58-
require.Equal(t, defaultScheduleParsed.Time(), sched1.Time)
58+
require.Equal(t, defaultScheduleParsed.TimeParsed().Format("15:40"), sched1.Time)
5959
require.Equal(t, defaultScheduleParsed.Location().String(), sched1.Timezone)
6060
require.WithinDuration(t, defaultScheduleParsed.Next(time.Now()), sched1.Next, 15*time.Second)
6161

@@ -78,7 +78,7 @@ func TestUserQuietHours(t *testing.T) {
7878
require.NoError(t, err)
7979
require.Equal(t, customScheduleParsed.String(), sched2.RawSchedule)
8080
require.True(t, sched2.UserSet)
81-
require.Equal(t, customScheduleParsed.Time(), sched2.Time)
81+
require.Equal(t, customScheduleParsed.TimeParsed().Format("15:40"), sched2.Time)
8282
require.Equal(t, customScheduleParsed.Location().String(), sched2.Timezone)
8383
require.WithinDuration(t, customScheduleParsed.Next(time.Now()), sched2.Next, 15*time.Second)
8484

@@ -87,7 +87,7 @@ func TestUserQuietHours(t *testing.T) {
8787
require.NoError(t, err)
8888
require.Equal(t, customScheduleParsed.String(), sched3.RawSchedule)
8989
require.True(t, sched3.UserSet)
90-
require.Equal(t, customScheduleParsed.Time(), sched3.Time)
90+
require.Equal(t, customScheduleParsed.TimeParsed().Format("15:40"), sched3.Time)
9191
require.Equal(t, customScheduleParsed.Location().String(), sched3.Timezone)
9292
require.WithinDuration(t, customScheduleParsed.Next(time.Now()), sched3.Next, 15*time.Second)
9393

0 commit comments

Comments
 (0)