1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package secrets
// This file contains convenience functions for working with a secrets
// client. These will be mostly only useful in the main method of
// a program because most of them are designed to terminate the
// application with a log message or panic.
import (
"context"
"log"
)
func MustGetApiKey(c Client, ctx context.Context, path string) *ApiKey {
key := &ApiKey{}
if _, err := c.Secret(ctx, path, key); err != nil {
log.Fatalf("Error fetching API key secret %s: %s", path, err)
}
return key
}
func MustGetCredential(c Client, ctx context.Context, path string) *Credential {
cred := &Credential{}
if _, err := c.Secret(ctx, path, cred); err != nil {
log.Fatalf("Error fetching credential secret %s: %s", path, err)
}
return cred
}
func MustGetRSAKey(c Client, ctx context.Context, path string) *RSAKey {
key := &RSAKey{}
if _, err := c.Secret(ctx, path, key); err != nil {
log.Fatalf("Error fetching RSA key %s: %s", path, err)
}
return key
}
|