Skip to content

Commit c58140e

Browse files
committed
Merge branch 'main' into breadcrumbs
2 parents d6da00b + 5246f8d commit c58140e

File tree

96 files changed

+1725
-891
lines changed

Some content is hidden

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

96 files changed

+1725
-891
lines changed

cli/testdata/coder_list_--output_json.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"owner_name": "testuser",
88
"owner_avatar_url": "",
99
"organization_id": "[first org ID]",
10-
"organization_name": "first-organization",
10+
"organization_name": "coder",
1111
"template_id": "[template ID]",
1212
"template_name": "test-template",
1313
"template_display_name": "",

coderd/apidoc/docs.go

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

coderd/apidoc/swagger.json

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

coderd/database/dbauthz/dbauthz.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,13 @@ func (q *querier) GetCryptoKeys(ctx context.Context) ([]database.CryptoKey, erro
14051405
return q.db.GetCryptoKeys(ctx)
14061406
}
14071407

1408+
func (q *querier) GetCryptoKeysByFeature(ctx context.Context, feature database.CryptoKeyFeature) ([]database.CryptoKey, error) {
1409+
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceCryptoKey); err != nil {
1410+
return nil, err
1411+
}
1412+
return q.db.GetCryptoKeysByFeature(ctx, feature)
1413+
}
1414+
14081415
func (q *querier) GetDBCryptKeys(ctx context.Context) ([]database.DBCryptKey, error) {
14091416
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceSystem); err != nil {
14101417
return nil, err

coderd/database/dbauthz/dbauthz_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,6 +2302,10 @@ func (s *MethodTestSuite) TestCryptoKeys() {
23022302
DeletesAt: sql.NullTime{Time: time.Now(), Valid: true},
23032303
}).Asserts(rbac.ResourceCryptoKey, policy.ActionUpdate)
23042304
}))
2305+
s.Run("GetCryptoKeysByFeature", s.Subtest(func(db database.Store, check *expects) {
2306+
check.Args(database.CryptoKeyFeatureWorkspaceApps).
2307+
Asserts(rbac.ResourceCryptoKey, policy.ActionRead)
2308+
}))
23052309
}
23062310

23072311
func (s *MethodTestSuite) TestSystemFunctions() {

coderd/database/dbmem/dbmem.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ func New() database.Store {
9292
// Always start with a default org. Matching migration 198.
9393
defaultOrg, err := q.InsertOrganization(context.Background(), database.InsertOrganizationParams{
9494
ID: uuid.New(),
95-
Name: "first-organization",
96-
DisplayName: "first-organization",
95+
Name: "coder",
96+
DisplayName: "Coder",
9797
Description: "Builtin default organization.",
9898
Icon: "",
9999
CreatedAt: dbtime.Now(),
@@ -2429,6 +2429,23 @@ func (q *FakeQuerier) GetCryptoKeys(_ context.Context) ([]database.CryptoKey, er
24292429
return keys, nil
24302430
}
24312431

2432+
func (q *FakeQuerier) GetCryptoKeysByFeature(_ context.Context, feature database.CryptoKeyFeature) ([]database.CryptoKey, error) {
2433+
q.mutex.RLock()
2434+
defer q.mutex.RUnlock()
2435+
2436+
keys := make([]database.CryptoKey, 0)
2437+
for _, key := range q.cryptoKeys {
2438+
if key.Feature == feature && key.Secret.Valid {
2439+
keys = append(keys, key)
2440+
}
2441+
}
2442+
// We want to return the highest sequence number first.
2443+
slices.SortFunc(keys, func(i, j database.CryptoKey) int {
2444+
return int(j.Sequence - i.Sequence)
2445+
})
2446+
return keys, nil
2447+
}
2448+
24322449
func (q *FakeQuerier) GetDBCryptKeys(_ context.Context) ([]database.DBCryptKey, error) {
24332450
q.mutex.RLock()
24342451
defer q.mutex.RUnlock()

coderd/database/dbmetrics/dbmetrics.go

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

coderd/database/dbmock/dbmock.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Leave the name as 'coder', there is no downside.
2+
-- The old name 'first-organization' is not used anywhere, just the
3+
-- is_default property.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
UPDATE
2+
organizations
3+
SET
4+
name = 'coder',
5+
display_name = 'Coder'
6+
WHERE
7+
-- The old name was too long.
8+
name = 'first-organization'
9+
AND is_default = true
10+
;

0 commit comments

Comments
 (0)