This repository has been archived by the owner on Jan 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
63 lines (55 loc) · 1.47 KB
/
options.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
package vault
import (
"context"
"github.com/boxgo/config/source"
)
type addressKey struct{}
type resourcePath struct{}
type nameSpace struct{}
type tokenKey struct{}
type secretName struct{}
// WithAddress sets the server address
func WithAddress(a string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, addressKey{}, a)
}
}
// WithResourcePath sets the resource that will be access
func WithResourcePath(p string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, resourcePath{}, p)
}
}
// WithNameSpace sets the namespace that its going to be access
func WithNameSpace(n string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, nameSpace{}, n)
}
}
// WithToken sets the key token to use
func WithToken(t string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, tokenKey{}, t)
}
}
// WithSecretName sets the name of the secret to wrap in on a map
func WithSecretName(t string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, secretName{}, t)
}
}