Skip to content

Commit fb2e7c3

Browse files
committed
Merge branch 'main' into 3522-workspacebuilds-1
2 parents 6bb31ce + e6b17b6 commit fb2e7c3

File tree

94 files changed

+2774
-4882
lines changed

Some content is hidden

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

94 files changed

+2774
-4882
lines changed

.github/workflows/packages.yaml

+16-5
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ jobs:
1515
run: |
1616
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
1717
18-
# the package version is the same as the release tag without the leading
19-
# "v", and with a trailing ".0" (e.g. "v1.2.3" -> "1.2.3.0")
18+
# The package version is the same as the tag minus the leading "v".
2019
- name: Calculate package version
2120
id: version
2221
run: |
2322
$version = $env:CODER_VERSION -replace "^v", ""
24-
$version += ".0"
2523
echo "::set-output name=version::$version"
2624
2725
- name: Submit updated manifest to winget-pkgs
@@ -35,17 +33,30 @@ jobs:
3533
3634
echo "Installer URL: $installer_url"
3735
36+
# The URL "|X64" suffix forces the architecture as it cannot be
37+
# sniffed properly from the URL. wingetcreate checks both the URL and
38+
# binary magic bytes for the architecture and they need to both match,
39+
# but they only check for `x64`, `win64` and `_64` in the URL. Our URL
40+
# contains `amd64` which doesn't match sadly.
41+
#
42+
# wingetcreate will still do the binary magic bytes check, so if we
43+
# accidentally change the architecture of the installer, it will fail
44+
# submission.
3845
.\wingetcreate.exe update Coder.Coder `
3946
--submit `
4047
--version "${{ steps.version.outputs.version }}" `
41-
--urls "$installer_url" `
48+
--urls "${installer_url}|X64" `
4249
--token "${{ secrets.CDRCI_GITHUB_TOKEN }}"
4350
51+
env:
52+
# For gh CLI:
53+
GH_TOKEN: ${{ github.token }}
54+
4455
- name: Comment on PR
4556
run: |
4657
# find the PR that wingetcreate just made
4758
$pr_list = gh pr list --repo microsoft/winget-pkgs --search "author:cdrci Coder.Coder version ${{ steps.version.outputs.version }}" --limit 1 --json number | `
4859
ConvertFrom-Json`
4960
$pr_number = $pr_list[0].number
5061
51-
gh pr comment --repo microsoft/winget-pkgs "$pr_number" --body "🤖 cc: @deansheather"
62+
gh pr comment --repo microsoft/winget-pkgs "$pr_number" --body "🤖 cc: @deansheather @matifali"

.github/workflows/stale.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
# v5.1.0 has a weird bug that makes stalebot add then remove its own label
1515
# https://github.com/actions/stale/pull/775
16-
- uses: actions/stale@v6.0.0
16+
- uses: actions/stale@v7.0.0
1717
with:
1818
stale-issue-label: "stale"
1919
stale-pr-label: "stale"

cli/deployment/config.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ func newConfig() *codersdk.DeploymentConfig {
248248
Flag: "oidc-ignore-email-verified",
249249
Default: false,
250250
},
251+
UsernameField: &codersdk.DeploymentConfigField[string]{
252+
Name: "OIDC Username Field",
253+
Usage: "OIDC claim field to use as the username.",
254+
Flag: "oidc-username-field",
255+
Default: "preferred_username",
256+
},
251257
},
252258

253259
Telemetry: &codersdk.TelemetryConfig{
@@ -356,12 +362,6 @@ func newConfig() *codersdk.DeploymentConfig {
356362
Flag: "ssh-keygen-algorithm",
357363
Default: "ed25519",
358364
},
359-
AutoImportTemplates: &codersdk.DeploymentConfigField[[]string]{
360-
Name: "Auto Import Templates",
361-
Usage: "Templates to auto-import. Available auto-importable templates are: kubernetes",
362-
Flag: "auto-import-template",
363-
Hidden: true,
364-
},
365365
MetricsCacheRefreshInterval: &codersdk.DeploymentConfigField[time.Duration]{
366366
Name: "Metrics Cache Refresh Interval",
367367
Usage: "How frequently metrics are refreshed",

cli/server.go

+3-24
Original file line numberDiff line numberDiff line change
@@ -371,27 +371,6 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
371371
return xerrors.Errorf("parse ssh keygen algorithm %s: %w", cfg.SSHKeygenAlgorithm.Value, err)
372372
}
373373

374-
// Validate provided auto-import templates.
375-
var (
376-
validatedAutoImportTemplates = make([]coderd.AutoImportTemplate, len(cfg.AutoImportTemplates.Value))
377-
seenValidatedAutoImportTemplates = make(map[coderd.AutoImportTemplate]struct{}, len(cfg.AutoImportTemplates.Value))
378-
)
379-
for i, autoImportTemplate := range cfg.AutoImportTemplates.Value {
380-
var v coderd.AutoImportTemplate
381-
switch autoImportTemplate {
382-
case "kubernetes":
383-
v = coderd.AutoImportTemplateKubernetes
384-
default:
385-
return xerrors.Errorf("auto import template %q is not supported", autoImportTemplate)
386-
}
387-
388-
if _, ok := seenValidatedAutoImportTemplates[v]; ok {
389-
return xerrors.Errorf("auto import template %q is specified more than once", v)
390-
}
391-
seenValidatedAutoImportTemplates[v] = struct{}{}
392-
validatedAutoImportTemplates[i] = v
393-
}
394-
395374
defaultRegion := &tailcfg.DERPRegion{
396375
EmbeddedRelay: true,
397376
RegionID: cfg.DERP.Server.RegionID.Value,
@@ -449,7 +428,6 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
449428
SSHKeygenAlgorithm: sshKeygenAlgorithm,
450429
TracerProvider: tracerProvider,
451430
Telemetry: telemetry.NewNoop(),
452-
AutoImportTemplates: validatedAutoImportTemplates,
453431
MetricsCacheRefreshInterval: cfg.MetricsCacheRefreshInterval.Value,
454432
AgentStatsRefreshInterval: cfg.AgentStatRefreshInterval.Value,
455433
DeploymentConfig: cfg,
@@ -526,8 +504,9 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
526504
Verifier: oidcProvider.Verifier(&oidc.Config{
527505
ClientID: cfg.OIDC.ClientID.Value,
528506
}),
529-
EmailDomain: cfg.OIDC.EmailDomain.Value,
530-
AllowSignups: cfg.OIDC.AllowSignups.Value,
507+
EmailDomain: cfg.OIDC.EmailDomain.Value,
508+
AllowSignups: cfg.OIDC.AllowSignups.Value,
509+
UsernameField: cfg.OIDC.UsernameField.Value,
531510
}
532511
}
533512

cli/testdata/coder_server_--help.golden

+3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ Flags:
112112
OIDC.
113113
Consumes $CODER_OIDC_SCOPES (default
114114
[openid,profile,email])
115+
--oidc-username-field string OIDC claim field to use as the username.
116+
Consumes $CODER_OIDC_USERNAME_FIELD
117+
(default "preferred_username")
115118
--postgres-url string URL of a PostgreSQL database. If empty,
116119
PostgreSQL binaries will be downloaded
117120
from Maven

coderd/apidoc/docs.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2331,9 +2331,6 @@ const docTemplate = `{
23312331
"audit_logging": {
23322332
"$ref": "#/definitions/codersdk.DeploymentConfigField-bool"
23332333
},
2334-
"auto_import_templates": {
2335-
"$ref": "#/definitions/codersdk.DeploymentConfigField-array_string"
2336-
},
23372334
"autobuild_poll_interval": {
23382335
"$ref": "#/definitions/codersdk.DeploymentConfigField-time_Duration"
23392336
},
@@ -2744,6 +2741,9 @@ const docTemplate = `{
27442741
},
27452742
"scopes": {
27462743
"$ref": "#/definitions/codersdk.DeploymentConfigField-array_string"
2744+
},
2745+
"username_field": {
2746+
"$ref": "#/definitions/codersdk.DeploymentConfigField-string"
27472747
}
27482748
}
27492749
},

coderd/apidoc/swagger.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2064,9 +2064,6 @@
20642064
"audit_logging": {
20652065
"$ref": "#/definitions/codersdk.DeploymentConfigField-bool"
20662066
},
2067-
"auto_import_templates": {
2068-
"$ref": "#/definitions/codersdk.DeploymentConfigField-array_string"
2069-
},
20702067
"autobuild_poll_interval": {
20712068
"$ref": "#/definitions/codersdk.DeploymentConfigField-time_Duration"
20722069
},
@@ -2475,6 +2472,9 @@
24752472
},
24762473
"scopes": {
24772474
"$ref": "#/definitions/codersdk.DeploymentConfigField-array_string"
2475+
},
2476+
"username_field": {
2477+
"$ref": "#/definitions/codersdk.DeploymentConfigField-string"
24782478
}
24792479
}
24802480
},

coderd/audit/request.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func InitRequest[T Auditable](w http.ResponseWriter, p *RequestParams) (*Request
157157
}
158158

159159
ip := parseIP(p.Request.RemoteAddr)
160-
err := p.Audit.Export(ctx, database.AuditLog{
160+
auditLog := database.AuditLog{
161161
ID: uuid.New(),
162162
Time: database.Now(),
163163
UserID: httpmw.APIKey(p.Request).UserID,
@@ -171,9 +171,13 @@ func InitRequest[T Auditable](w http.ResponseWriter, p *RequestParams) (*Request
171171
StatusCode: int32(sw.Status),
172172
RequestID: httpmw.RequestID(p.Request),
173173
AdditionalFields: p.AdditionalFields,
174-
})
174+
}
175+
err := p.Audit.Export(ctx, auditLog)
175176
if err != nil {
176-
p.Log.Error(logCtx, "export audit log", slog.Error(err))
177+
p.Log.Error(logCtx, "export audit log",
178+
slog.F("audit_log", auditLog),
179+
slog.Error(err),
180+
)
177181
return
178182
}
179183
}
@@ -192,7 +196,7 @@ func BuildAudit[T Auditable](ctx context.Context, p *BuildAuditParams[T]) {
192196
p.AdditionalFields = json.RawMessage("{}")
193197
}
194198

195-
err := p.Audit.Export(ctx, database.AuditLog{
199+
auditLog := database.AuditLog{
196200
ID: uuid.New(),
197201
Time: database.Now(),
198202
UserID: p.UserID,
@@ -206,9 +210,13 @@ func BuildAudit[T Auditable](ctx context.Context, p *BuildAuditParams[T]) {
206210
StatusCode: int32(p.Status),
207211
RequestID: p.JobID,
208212
AdditionalFields: p.AdditionalFields,
209-
})
213+
}
214+
err := p.Audit.Export(ctx, auditLog)
210215
if err != nil {
211-
p.Log.Error(ctx, "export audit log", slog.Error(err))
216+
p.Log.Error(ctx, "export audit log",
217+
slog.F("audit_log", auditLog),
218+
slog.Error(err),
219+
)
212220
return
213221
}
214222
}

coderd/coderd.go

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ type Options struct {
9797
SSHKeygenAlgorithm gitsshkey.Algorithm
9898
Telemetry telemetry.Reporter
9999
TracerProvider trace.TracerProvider
100-
AutoImportTemplates []AutoImportTemplate
101100
GitAuthConfigs []*gitauth.Config
102101
RealIPConfig *httpmw.RealIPConfig
103102
TrialGenerator func(ctx context.Context, email string) error

coderd/coderdtest/coderdtest.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ type Options struct {
9393
GoogleTokenValidator *idtoken.Validator
9494
SSHKeygenAlgorithm gitsshkey.Algorithm
9595
APIRateLimit int
96-
AutoImportTemplates []coderd.AutoImportTemplate
9796
AutobuildTicker <-chan time.Time
9897
AutobuildStats chan<- executor.Stats
9998
Auditor audit.Auditor
@@ -294,7 +293,6 @@ func NewOptions(t *testing.T, options *Options) (func(http.Handler), context.Can
294293
},
295294
},
296295
},
297-
AutoImportTemplates: options.AutoImportTemplates,
298296
MetricsCacheRefreshInterval: options.MetricsCacheRefreshInterval,
299297
AgentStatsRefreshInterval: options.AgentStatsRefreshInterval,
300298
DeploymentConfig: options.DeploymentConfig,
@@ -880,6 +878,7 @@ func (o *OIDCConfig) OIDCConfig() *coderd.OIDCConfig {
880878
}, &oidc.Config{
881879
SkipClientIDCheck: true,
882880
}),
881+
UsernameField: "preferred_username",
883882
}
884883
}
885884

coderd/database/databasefake/databasefake.go

+20
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ type data struct {
123123
derpMeshKey string
124124
lastUpdateCheck []byte
125125
serviceBanner []byte
126+
logoURL string
126127
lastLicenseID int32
127128
}
128129

@@ -3356,6 +3357,25 @@ func (q *fakeQuerier) GetServiceBanner(_ context.Context) (string, error) {
33563357
return string(q.serviceBanner), nil
33573358
}
33583359

3360+
func (q *fakeQuerier) InsertOrUpdateLogoURL(_ context.Context, data string) error {
3361+
q.mutex.RLock()
3362+
defer q.mutex.RUnlock()
3363+
3364+
q.logoURL = data
3365+
return nil
3366+
}
3367+
3368+
func (q *fakeQuerier) GetLogoURL(_ context.Context) (string, error) {
3369+
q.mutex.RLock()
3370+
defer q.mutex.RUnlock()
3371+
3372+
if q.logoURL == "" {
3373+
return "", sql.ErrNoRows
3374+
}
3375+
3376+
return q.logoURL, nil
3377+
}
3378+
33593379
func (q *fakeQuerier) InsertLicense(
33603380
_ context.Context, arg database.InsertLicenseParams,
33613381
) (database.License, error) {

coderd/database/querier.go

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

coderd/database/queries.sql.go

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

coderd/database/queries/siteconfig.sql

+7
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ ON CONFLICT (key) DO UPDATE SET value = $1 WHERE site_configs.key = 'service_ban
2323

2424
-- name: GetServiceBanner :one
2525
SELECT value FROM site_configs WHERE key = 'service_banner';
26+
27+
-- name: InsertOrUpdateLogoURL :exec
28+
INSERT INTO site_configs (key, value) VALUES ('logo_url', $1)
29+
ON CONFLICT (key) DO UPDATE SET value = $1 WHERE site_configs.key = 'logo_url';
30+
31+
-- name: GetLogoURL :one
32+
SELECT value FROM site_configs WHERE key = 'logo_url';

0 commit comments

Comments
 (0)