feat: add tags to provisioner keys api (#13989)

This commit is contained in:
Garrett Delfosse
2024-07-25 11:20:45 -04:00
committed by GitHub
parent ca83017dc1
commit 6161d173d3
21 changed files with 120 additions and 49 deletions
+6 -1
View File
@@ -14,7 +14,7 @@ import (
"github.com/coder/coder/v2/cryptorand"
)
func New(organizationID uuid.UUID, name string) (database.InsertProvisionerKeyParams, string, error) {
func New(organizationID uuid.UUID, name string, tags map[string]string) (database.InsertProvisionerKeyParams, string, error) {
id := uuid.New()
secret, err := cryptorand.HexString(64)
if err != nil {
@@ -23,12 +23,17 @@ func New(organizationID uuid.UUID, name string) (database.InsertProvisionerKeyPa
hashedSecret := HashSecret(secret)
token := fmt.Sprintf("%s:%s", id, secret)
if tags == nil {
tags = map[string]string{}
}
return database.InsertProvisionerKeyParams{
ID: id,
CreatedAt: dbtime.Now(),
OrganizationID: organizationID,
Name: name,
HashedSecret: hashedSecret,
Tags: tags,
}, token, nil
}