Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2090d2a

Browse files
committed
feat: add tags to provisioner keys api
1 parentca83017 commit2090d2a

File tree

17 files changed

+86
-33
lines changed

17 files changed

+86
-33
lines changed

‎coderd/apidoc/docs.go

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

‎coderd/apidoc/swagger.json

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

‎coderd/database/dbmem/dbmem.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6586,6 +6586,7 @@ func (q *FakeQuerier) InsertProvisionerKey(_ context.Context, arg database.Inser
65866586
OrganizationID:arg.OrganizationID,
65876587
Name:strings.ToLower(arg.Name),
65886588
HashedSecret:arg.HashedSecret,
6589+
Tags:arg.Tags,
65896590
}
65906591
q.provisionerKeys=append(q.provisionerKeys,provisionerKey)
65916592

@@ -7276,13 +7277,7 @@ func (q *FakeQuerier) ListProvisionerKeysByOrganization(_ context.Context, organ
72767277
keys:=make([]database.ProvisionerKey,0)
72777278
for_,key:=rangeq.provisionerKeys {
72787279
ifkey.OrganizationID==organizationID {
7279-
keys=append(keys, database.ProvisionerKey{
7280-
ID:key.ID,
7281-
CreatedAt:key.CreatedAt,
7282-
OrganizationID:key.OrganizationID,
7283-
Name:key.Name,
7284-
HashedSecret:key.HashedSecret,
7285-
})
7280+
keys=append(keys,key)
72867281
}
72877282
}
72887283

‎coderd/database/dump.sql

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTERTABLE provisioner_keys DROP COLUMN tags;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTERTABLE provisioner_keys ADD COLUMN tags jsonb DEFAULT'{}'::jsonbNOT NULL;
2+
ALTERTABLE provisioner_keys ALTER COLUMN tags DROP DEFAULT;

‎coderd/database/models.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go

Lines changed: 12 additions & 5 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/provisionerkeys.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ INSERT INTO
55
created_at,
66
organization_id,
77
name,
8-
hashed_secret
8+
hashed_secret,
9+
tags
910
)
1011
VALUES
11-
($1, $2, $3,lower(@name), $4) RETURNING*;
12+
($1, $2, $3,lower(@name), $4, $5) RETURNING*;
1213

1314
-- name: GetProvisionerKeyByID :one
1415
SELECT

‎coderd/database/sqlc.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ sql:
4444
-column:"provisioner_daemons.tags"
4545
go_type:
4646
type:"StringMap"
47+
-column:"provisioner_keys.tags"
48+
go_type:
49+
type:"StringMap"
4750
-column:"provisioner_jobs.tags"
4851
go_type:
4952
type:"StringMap"

‎coderd/provisionerkey/provisionerkey.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/coder/coder/v2/cryptorand"
1515
)
1616

17-
funcNew(organizationID uuid.UUID,namestring) (database.InsertProvisionerKeyParams,string,error) {
17+
funcNew(organizationID uuid.UUID,namestring,tagsmap[string]string) (database.InsertProvisionerKeyParams,string,error) {
1818
id:=uuid.New()
1919
secret,err:=cryptorand.HexString(64)
2020
iferr!=nil {
@@ -23,12 +23,17 @@ func New(organizationID uuid.UUID, name string) (database.InsertProvisionerKeyPa
2323
hashedSecret:=HashSecret(secret)
2424
token:=fmt.Sprintf("%s:%s",id,secret)
2525

26+
iftags==nil {
27+
tags=map[string]string{}
28+
}
29+
2630
return database.InsertProvisionerKeyParams{
2731
ID:id,
2832
CreatedAt:dbtime.Now(),
2933
OrganizationID:organizationID,
3034
Name:name,
3135
HashedSecret:hashedSecret,
36+
Tags:tags,
3237
},token,nil
3338
}
3439

‎codersdk/provisionerdaemons.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,12 @@ type ProvisionerKey struct {
279279
OrganizationID uuid.UUID`json:"organization" table:"organization_id" format:"uuid"`
280280
Namestring`json:"name" table:"name,default_sort"`
281281
// HashedSecret - never include the access token in the API response
282+
Tagsmap[string]string`json:"tags" table:"tags"`
282283
}
283284

284285
typeCreateProvisionerKeyRequeststruct {
285-
Namestring`json:"name"`
286+
Namestring`json:"name"`
287+
Tagsmap[string]string`json:"tags"`
286288
}
287289

288290
typeCreateProvisionerKeyResponsestruct {

‎docs/api/enterprise.md

Lines changed: 14 additions & 8 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/api/schemas.md

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

‎enterprise/coderd/provisionerkeys.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (api *API) postProvisionerKey(rw http.ResponseWriter, r *http.Request) {
5454
return
5555
}
5656

57-
params,token,err:=provisionerkey.New(organization.ID,req.Name)
57+
params,token,err:=provisionerkey.New(organization.ID,req.Name,req.Tags)
5858
iferr!=nil {
5959
httpapi.InternalServerError(rw,err)
6060
return
@@ -143,6 +143,7 @@ func convertProvisionerKeys(dbKeys []database.ProvisionerKey) []codersdk.Provisi
143143
OrganizationID:dbKey.OrganizationID,
144144
Name:dbKey.Name,
145145
// HashedSecret - never include the access token in the API response
146+
Tags:dbKey.Tags,
146147
})
147148
}
148149
returnkeys

‎enterprise/coderd/provisionerkeys_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,13 @@ func TestProvisionerKeys(t *testing.T) {
6969
require.NoError(t,err,"org admin list provisioner keys")
7070
require.Len(t,keys,0,"org admin list provisioner keys")
7171

72+
tags:=map[string]string{
73+
"my":"way",
74+
}
7275
// org admin can create a provisioner key
7376
_,err=orgAdmin.CreateProvisionerKey(ctx,owner.OrganizationID, codersdk.CreateProvisionerKeyRequest{
7477
Name:"Key",// case insensitive
78+
Tags:tags,
7579
})
7680
require.NoError(t,err,"org admin create provisioner key")
7781

@@ -97,6 +101,8 @@ func TestProvisionerKeys(t *testing.T) {
97101
keys,err=orgAdmin.ListProvisionerKeys(ctx,owner.OrganizationID)
98102
require.NoError(t,err,"org admin list provisioner keys")
99103
require.Len(t,keys,1,"org admin list provisioner keys")
104+
require.Equal(t,"key",keys[0].Name,"org admin list provisioner keys name matches")
105+
require.EqualValues(t,tags,keys[0].Tags,"org admin list provisioner keys tags match")
100106

101107
// org admin can delete a provisioner key
102108
err=orgAdmin.DeleteProvisionerKey(ctx,owner.OrganizationID,"key")// using lowercase here works

‎site/src/api/typesGenerated.ts

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp