forked from concourse/concourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vault_factory.go
43 lines (36 loc) · 1.08 KB
/
vault_factory.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
package vault
import (
"time"
"github.com/pf-qiu/concourse/v6/atc/creds"
)
// The vaultFactory will return a vault implementation of vars.Variables.
type vaultFactory struct {
sr SecretReader
prefix string
sharedPath string
lookupTemplates []*creds.SecretTemplate
loggedIn <-chan struct{}
}
func NewVaultFactory(sr SecretReader, loggedIn <-chan struct{}, prefix string, lookupTemplates []*creds.SecretTemplate, sharedPath string) *vaultFactory {
factory := &vaultFactory{
sr: sr,
prefix: prefix,
lookupTemplates: lookupTemplates,
sharedPath: sharedPath,
loggedIn: loggedIn,
}
return factory
}
// NewSecrets will block until the loggedIn channel passed to the constructor signals a successful login.
func (factory *vaultFactory) NewSecrets() creds.Secrets {
select {
case <-factory.loggedIn:
case <-time.After(5 * time.Second):
}
return &Vault{
SecretReader: factory.sr,
Prefix: factory.prefix,
LookupTemplates: factory.lookupTemplates,
SharedPath: factory.sharedPath,
}
}