Skip to content

Commit 709b669

Browse files
committed
Merge branch 'main' of https://github.com/coder/coder into bq/add-agent-timings
2 parents 0b685a9 + 591cefa commit 709b669

39 files changed

+888
-95
lines changed

.github/workflows/docker-base.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@ on:
2222

2323
permissions:
2424
contents: read
25-
# Necessary to push docker images to ghcr.io.
26-
packages: write
27-
# Necessary for depot.dev authentication.
28-
id-token: write
2925

3026
# Avoid running multiple jobs for the same commit.
3127
concurrency:
3228
group: ${{ github.workflow }}-${{ github.ref }}-docker-base
3329

3430
jobs:
3531
build:
32+
permissions:
33+
# Necessary for depot.dev authentication.
34+
id-token: write
35+
# Necessary to push docker images to ghcr.io.
36+
packages: write
3637
runs-on: ubuntu-latest
3738
if: github.repository_owner == 'coder'
3839
steps:

.github/workflows/nightly-gauntlet.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
# Every day at midnight
77
- cron: "0 0 * * *"
88
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
913
jobs:
1014
go-race:
1115
# While GitHub's toaster runners are likelier to flake, we want consistency

.github/workflows/pr-cleanup.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ on:
88
description: "PR number"
99
required: true
1010

11-
permissions:
12-
packages: write
13-
1411
jobs:
1512
cleanup:
1613
runs-on: "ubuntu-latest"
14+
permissions:
15+
# Necessary to delete docker images from ghcr.io.
16+
packages: write
1717
steps:
1818
- name: Harden Runner
1919
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1

.github/workflows/pr-deploy.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ env:
3030

3131
permissions:
3232
contents: read
33-
packages: write
34-
pull-requests: write # needed for commenting on PRs
3533

3634
jobs:
3735
check_pr:
@@ -171,6 +169,8 @@ jobs:
171169
needs: get_info
172170
if: needs.get_info.outputs.BUILD == 'true' || github.event.inputs.deploy == 'true'
173171
runs-on: "ubuntu-latest"
172+
permissions:
173+
pull-requests: write # needed for commenting on PRs
174174
steps:
175175
- name: Harden Runner
176176
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
@@ -205,6 +205,9 @@ jobs:
205205
# Run build job only if there are changes in the files that we care about or if the workflow is manually triggered with --build flag
206206
if: needs.get_info.outputs.BUILD == 'true'
207207
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
208+
permissions:
209+
# Necessary to push docker images to ghcr.io.
210+
packages: write
208211
# This concurrency only cancels build jobs if a new build is triggred. It will avoid cancelling the current deployemtn in case of docs chnages.
209212
concurrency:
210213
group: build-${{ github.workflow }}-${{ github.ref }}-${{ needs.get_info.outputs.BUILD }}

.github/workflows/release-validation.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
tags:
66
- "v*"
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
network-performance:
1013
runs-on: ubuntu-latest

.github/workflows/release.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ on:
1818
default: false
1919

2020
permissions:
21-
# Required to publish a release
22-
contents: write
23-
# Necessary to push docker images to ghcr.io.
24-
packages: write
25-
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
26-
id-token: write
21+
contents: read
2722

2823
concurrency: ${{ github.workflow }}-${{ github.ref }}
2924

@@ -40,6 +35,13 @@ jobs:
4035
release:
4136
name: Build and publish
4237
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
38+
permissions:
39+
# Required to publish a release
40+
contents: write
41+
# Necessary to push docker images to ghcr.io.
42+
packages: write
43+
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
44+
id-token: write
4345
env:
4446
# Necessary for Docker manifest
4547
DOCKER_CLI_EXPERIMENTAL: "enabled"

.github/workflows/stale.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
name: Stale Issue, Banch and Old Workflows Cleanup
1+
name: Stale Issue, Branch and Old Workflows Cleanup
22
on:
33
schedule:
44
# Every day at midnight
55
- cron: "0 0 * * *"
66
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
711
jobs:
812
issues:
913
runs-on: ubuntu-latest
1014
permissions:
15+
# Needed to close issues.
1116
issues: write
17+
# Needed to close PRs.
1218
pull-requests: write
13-
actions: write
1419
steps:
1520
- name: Harden Runner
1621
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
@@ -86,6 +91,9 @@ jobs:
8691
8792
branches:
8893
runs-on: ubuntu-latest
94+
permissions:
95+
# Needed to delete branches.
96+
contents: write
8997
steps:
9098
- name: Harden Runner
9199
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
@@ -105,6 +113,9 @@ jobs:
105113
exclude_open_pr_branches: true
106114
del_runs:
107115
runs-on: ubuntu-latest
116+
permissions:
117+
# Needed to delete workflow runs.
118+
actions: write
108119
steps:
109120
- name: Harden Runner
110121
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1

cli/server.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,16 @@ func enablePrometheus(
212212
options.PrometheusRegistry.MustRegister(collectors.NewGoCollector())
213213
options.PrometheusRegistry.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
214214

215-
closeUsersFunc, err := prometheusmetrics.ActiveUsers(ctx, options.PrometheusRegistry, options.Database, 0)
215+
closeActiveUsersFunc, err := prometheusmetrics.ActiveUsers(ctx, options.Logger.Named("active_user_metrics"), options.PrometheusRegistry, options.Database, 0)
216216
if err != nil {
217217
return nil, xerrors.Errorf("register active users prometheus metric: %w", err)
218218
}
219+
afterCtx(ctx, closeActiveUsersFunc)
220+
221+
closeUsersFunc, err := prometheusmetrics.Users(ctx, options.Logger.Named("user_metrics"), quartz.NewReal(), options.PrometheusRegistry, options.Database, 0)
222+
if err != nil {
223+
return nil, xerrors.Errorf("register users prometheus metric: %w", err)
224+
}
219225
afterCtx(ctx, closeUsersFunc)
220226

221227
closeWorkspacesFunc, err := prometheusmetrics.Workspaces(ctx, options.Logger.Named("workspaces_metrics"), options.PrometheusRegistry, options.Database, 0)
@@ -1035,7 +1041,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
10351041
autobuildTicker := time.NewTicker(vals.AutobuildPollInterval.Value())
10361042
defer autobuildTicker.Stop()
10371043
autobuildExecutor := autobuild.NewExecutor(
1038-
ctx, options.Database, options.Pubsub, coderAPI.TemplateScheduleStore, &coderAPI.Auditor, coderAPI.AccessControlStore, logger, autobuildTicker.C, options.NotificationsEnqueuer)
1044+
ctx, options.Database, options.Pubsub, options.PrometheusRegistry, coderAPI.TemplateScheduleStore, &coderAPI.Auditor, coderAPI.AccessControlStore, logger, autobuildTicker.C, options.NotificationsEnqueuer)
10391045
autobuildExecutor.Run()
10401046

10411047
hangDetectorTicker := time.NewTicker(vals.JobHangDetectorInterval.Value())

cli/templatepush.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func (pf *templateUploadFlags) stdin(inv *serpent.Invocation) (out bool) {
282282
}
283283
}()
284284
// We let the directory override our isTTY check
285-
return pf.directory == "-" || (!isTTYIn(inv) && pf.directory == "")
285+
return pf.directory == "-" || (!isTTYIn(inv) && pf.directory == ".")
286286
}
287287

288288
func (pf *templateUploadFlags) upload(inv *serpent.Invocation, client *codersdk.Client) (*codersdk.UploadResponse, error) {

cli/testdata/coder_server_--help.golden

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,58 @@ Use a YAML configuration file when your server launch become unwieldy.
106106

107107
Write out the current server config as YAML to stdout.
108108

109+
EMAIL OPTIONS:
110+
Configure how emails are sent.
111+
112+
--email-force-tls bool, $CODER_EMAIL_FORCE_TLS (default: false)
113+
Force a TLS connection to the configured SMTP smarthost.
114+
115+
--email-from string, $CODER_EMAIL_FROM
116+
The sender's address to use.
117+
118+
--email-hello string, $CODER_EMAIL_HELLO (default: localhost)
119+
The hostname identifying the SMTP server.
120+
121+
--email-smarthost host:port, $CODER_EMAIL_SMARTHOST (default: localhost:587)
122+
The intermediary SMTP host through which emails are sent.
123+
124+
EMAIL / EMAIL AUTHENTICATION OPTIONS:
125+
Configure SMTP authentication options.
126+
127+
--email-auth-identity string, $CODER_EMAIL_AUTH_IDENTITY
128+
Identity to use with PLAIN authentication.
129+
130+
--email-auth-password string, $CODER_EMAIL_AUTH_PASSWORD
131+
Password to use with PLAIN/LOGIN authentication.
132+
133+
--email-auth-password-file string, $CODER_EMAIL_AUTH_PASSWORD_FILE
134+
File from which to load password for use with PLAIN/LOGIN
135+
authentication.
136+
137+
--email-auth-username string, $CODER_EMAIL_AUTH_USERNAME
138+
Username to use with PLAIN/LOGIN authentication.
139+
140+
EMAIL / EMAIL TLS OPTIONS:
141+
Configure TLS for your SMTP server target.
142+
143+
--email-tls-ca-cert-file string, $CODER_EMAIL_TLS_CACERTFILE
144+
CA certificate file to use.
145+
146+
--email-tls-cert-file string, $CODER_EMAIL_TLS_CERTFILE
147+
Certificate file to use.
148+
149+
--email-tls-cert-key-file string, $CODER_EMAIL_TLS_CERTKEYFILE
150+
Certificate key file to use.
151+
152+
--email-tls-server-name string, $CODER_EMAIL_TLS_SERVERNAME
153+
Server name to verify against the target certificate.
154+
155+
--email-tls-skip-verify bool, $CODER_EMAIL_TLS_SKIPVERIFY
156+
Skip verification of the target server's certificate (insecure).
157+
158+
--email-tls-starttls bool, $CODER_EMAIL_TLS_STARTTLS
159+
Enable STARTTLS to upgrade insecure SMTP connections using TLS.
160+
109161
INTROSPECTION / HEALTH CHECK OPTIONS:
110162
--health-check-refresh duration, $CODER_HEALTH_CHECK_REFRESH (default: 10m0s)
111163
Refresh interval for healthchecks.
@@ -349,54 +401,68 @@ Configure how notifications are processed and delivered.
349401
NOTIFICATIONS / EMAIL OPTIONS:
350402
Configure how email notifications are sent.
351403

352-
--notifications-email-force-tls bool, $CODER_NOTIFICATIONS_EMAIL_FORCE_TLS (default: false)
404+
--notifications-email-force-tls bool, $CODER_NOTIFICATIONS_EMAIL_FORCE_TLS
353405
Force a TLS connection to the configured SMTP smarthost.
406+
DEPRECATED: Use --email-force-tls instead.
354407

355408
--notifications-email-from string, $CODER_NOTIFICATIONS_EMAIL_FROM
356409
The sender's address to use.
410+
DEPRECATED: Use --email-from instead.
357411

358-
--notifications-email-hello string, $CODER_NOTIFICATIONS_EMAIL_HELLO (default: localhost)
412+
--notifications-email-hello string, $CODER_NOTIFICATIONS_EMAIL_HELLO
359413
The hostname identifying the SMTP server.
414+
DEPRECATED: Use --email-hello instead.
360415

361-
--notifications-email-smarthost host:port, $CODER_NOTIFICATIONS_EMAIL_SMARTHOST (default: localhost:587)
416+
--notifications-email-smarthost host:port, $CODER_NOTIFICATIONS_EMAIL_SMARTHOST
362417
The intermediary SMTP host through which emails are sent.
418+
DEPRECATED: Use --email-smarthost instead.
363419

364420
NOTIFICATIONS / EMAIL / EMAIL AUTHENTICATION OPTIONS:
365421
Configure SMTP authentication options.
366422

367423
--notifications-email-auth-identity string, $CODER_NOTIFICATIONS_EMAIL_AUTH_IDENTITY
368424
Identity to use with PLAIN authentication.
425+
DEPRECATED: Use --email-auth-identity instead.
369426

370427
--notifications-email-auth-password string, $CODER_NOTIFICATIONS_EMAIL_AUTH_PASSWORD
371428
Password to use with PLAIN/LOGIN authentication.
429+
DEPRECATED: Use --email-auth-password instead.
372430

373431
--notifications-email-auth-password-file string, $CODER_NOTIFICATIONS_EMAIL_AUTH_PASSWORD_FILE
374432
File from which to load password for use with PLAIN/LOGIN
375433
authentication.
434+
DEPRECATED: Use --email-auth-password-file instead.
376435

377436
--notifications-email-auth-username string, $CODER_NOTIFICATIONS_EMAIL_AUTH_USERNAME
378437
Username to use with PLAIN/LOGIN authentication.
438+
DEPRECATED: Use --email-auth-username instead.
379439

380440
NOTIFICATIONS / EMAIL / EMAIL TLS OPTIONS:
381441
Configure TLS for your SMTP server target.
382442

383443
--notifications-email-tls-ca-cert-file string, $CODER_NOTIFICATIONS_EMAIL_TLS_CACERTFILE
384444
CA certificate file to use.
445+
DEPRECATED: Use --email-tls-ca-cert-file instead.
385446

386447
--notifications-email-tls-cert-file string, $CODER_NOTIFICATIONS_EMAIL_TLS_CERTFILE
387448
Certificate file to use.
449+
DEPRECATED: Use --email-tls-cert-file instead.
388450

389451
--notifications-email-tls-cert-key-file string, $CODER_NOTIFICATIONS_EMAIL_TLS_CERTKEYFILE
390452
Certificate key file to use.
453+
DEPRECATED: Use --email-tls-cert-key-file instead.
391454

392455
--notifications-email-tls-server-name string, $CODER_NOTIFICATIONS_EMAIL_TLS_SERVERNAME
393456
Server name to verify against the target certificate.
457+
DEPRECATED: Use --email-tls-server-name instead.
394458

395459
--notifications-email-tls-skip-verify bool, $CODER_NOTIFICATIONS_EMAIL_TLS_SKIPVERIFY
396460
Skip verification of the target server's certificate (insecure).
461+
DEPRECATED: Use --email-tls-skip-verify instead.
397462

398463
--notifications-email-tls-starttls bool, $CODER_NOTIFICATIONS_EMAIL_TLS_STARTTLS
399464
Enable STARTTLS to upgrade insecure SMTP connections using TLS.
465+
DEPRECATED: Use --email-tls-starttls instead.
400466

401467
NOTIFICATIONS / WEBHOOK OPTIONS:
402468
--notifications-webhook-endpoint url, $CODER_NOTIFICATIONS_WEBHOOK_ENDPOINT

cli/testdata/server-config.yaml.golden

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,51 @@ userQuietHoursSchedule:
518518
# compatibility reasons, this will be removed in a future release.
519519
# (default: false, type: bool)
520520
allowWorkspaceRenames: false
521+
# Configure how emails are sent.
522+
email:
523+
# The sender's address to use.
524+
# (default: <unset>, type: string)
525+
from: ""
526+
# The intermediary SMTP host through which emails are sent.
527+
# (default: localhost:587, type: host:port)
528+
smarthost: localhost:587
529+
# The hostname identifying the SMTP server.
530+
# (default: localhost, type: string)
531+
hello: localhost
532+
# Force a TLS connection to the configured SMTP smarthost.
533+
# (default: false, type: bool)
534+
forceTLS: false
535+
# Configure SMTP authentication options.
536+
emailAuth:
537+
# Identity to use with PLAIN authentication.
538+
# (default: <unset>, type: string)
539+
identity: ""
540+
# Username to use with PLAIN/LOGIN authentication.
541+
# (default: <unset>, type: string)
542+
username: ""
543+
# File from which to load password for use with PLAIN/LOGIN authentication.
544+
# (default: <unset>, type: string)
545+
passwordFile: ""
546+
# Configure TLS for your SMTP server target.
547+
emailTLS:
548+
# Enable STARTTLS to upgrade insecure SMTP connections using TLS.
549+
# (default: <unset>, type: bool)
550+
startTLS: false
551+
# Server name to verify against the target certificate.
552+
# (default: <unset>, type: string)
553+
serverName: ""
554+
# Skip verification of the target server's certificate (insecure).
555+
# (default: <unset>, type: bool)
556+
insecureSkipVerify: false
557+
# CA certificate file to use.
558+
# (default: <unset>, type: string)
559+
caCertFile: ""
560+
# Certificate file to use.
561+
# (default: <unset>, type: string)
562+
certFile: ""
563+
# Certificate key file to use.
564+
# (default: <unset>, type: string)
565+
certKeyFile: ""
521566
# Configure how notifications are processed and delivered.
522567
notifications:
523568
# Which delivery method to use (available options: 'smtp', 'webhook').
@@ -532,13 +577,13 @@ notifications:
532577
# (default: <unset>, type: string)
533578
from: ""
534579
# The intermediary SMTP host through which emails are sent.
535-
# (default: localhost:587, type: host:port)
580+
# (default: <unset>, type: host:port)
536581
smarthost: localhost:587
537582
# The hostname identifying the SMTP server.
538-
# (default: localhost, type: string)
583+
# (default: <unset>, type: string)
539584
hello: localhost
540585
# Force a TLS connection to the configured SMTP smarthost.
541-
# (default: false, type: bool)
586+
# (default: <unset>, type: bool)
542587
forceTLS: false
543588
# Configure SMTP authentication options.
544589
emailAuth:

0 commit comments

Comments
 (0)