generated from brevdev/seed
-
Notifications
You must be signed in to change notification settings - Fork 14
/
secret.go
69 lines (54 loc) · 1.37 KB
/
secret.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package store
import breverrors "github.com/brevdev/brev-cli/pkg/errors"
type CreateSecretRequest struct {
Name string `json:"name"`
HierarchyType HierarchyType `json:"hierarchyType"`
HierarchyID string `json:"hierarchyID"`
Src SecretReqSrc `json:"src"`
Dest SecretReqDest `json:"dest"`
}
type HierarchyType string
const (
Org HierarchyType = "org"
User HierarchyType = "user"
)
type SecretReqDest struct {
Type DestType `json:"type"`
Config DestConfig `json:"config"`
}
type DestConfig struct {
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
}
type SecretReqSrc struct {
Type SrcType `json:"type"`
Config SrcConfig `json:"config"`
}
type SrcConfig struct {
Value string `json:"value"`
}
type SrcType string
const (
KeyValue SrcType = "kv2"
)
type DestType string
const (
File DestType = "file"
EnvVariable DestType = "env"
)
var secretsPath = "api/secrets"
func (s AuthHTTPStore) CreateSecret(req CreateSecretRequest) (*CreateSecretRequest, error) {
var result CreateSecretRequest
res, err := s.authHTTPClient.restyClient.R().
SetHeader("Content-Type", "application/json").
SetResult(&result).
SetBody(req).
Post(secretsPath)
if err != nil {
return nil, breverrors.WrapAndTrace(err)
}
if res.IsError() {
return nil, NewHTTPResponseError(res)
}
return &result, nil
}