MCPcopy Index your code
hub / github.com/coder/coder / New

Function New

coderd/provisionerkey/provisionerkey.go:18–36  ·  view source on GitHub ↗
(organizationID uuid.UUID, name string, tags map[string]string)

Source from the content-addressed store, hash-verified

16)
17
18func New(organizationID uuid.UUID, name string, tags map[string]string) (database.InsertProvisionerKeyParams, string, error) {
19 secret, hashed, err := apikey.GenerateSecret(secretLength)
20 if err != nil {
21 return database.InsertProvisionerKeyParams{}, "", xerrors.Errorf("generate secret: %w", err)
22 }
23
24 if tags == nil {
25 tags = map[string]string{}
26 }
27
28 return database.InsertProvisionerKeyParams{
29 ID: uuid.New(),
30 CreatedAt: dbtime.Now(),
31 OrganizationID: organizationID,
32 Name: name,
33 HashedSecret: hashed,
34 Tags: tags,
35 }, secret, nil
36}
37
38func Validate(token string) error {
39 if len(token) != secretLength {

Callers 2

postProvisionerKeyMethod · 0.92

Calls 4

GenerateSecretFunction · 0.92
NowFunction · 0.92
NewMethod · 0.65
ErrorfMethod · 0.45

Tested by 1