forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vault_factory.go
40 lines (33 loc) · 867 Bytes
/
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
package vault
import (
"time"
"github.com/concourse/atc/creds"
)
// The vaultFactory will return a vault implementation of creds.Variables.
type vaultFactory struct {
sr SecretReader
prefix string
loggedIn <-chan struct{}
}
func NewVaultFactory(sr SecretReader, loggedIn <-chan struct{}, prefix string) *vaultFactory {
factory := &vaultFactory{
sr: sr,
prefix: prefix,
loggedIn: loggedIn,
}
return factory
}
// NewVariables will block until the loggedIn channel passed to the
// constructor signals a successful login.
func (factory *vaultFactory) NewVariables(teamName string, pipelineName string) creds.Variables {
select {
case <-factory.loggedIn:
case <-time.After(5 * time.Second):
}
return &Vault{
SecretReader: factory.sr,
PathPrefix: factory.prefix,
TeamName: teamName,
PipelineName: pipelineName,
}
}