github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/atc/creds/vault/vault_factory.go (about) 1 package vault 2 3 import ( 4 "time" 5 6 "github.com/pf-qiu/concourse/v6/atc/creds" 7 ) 8 9 // The vaultFactory will return a vault implementation of vars.Variables. 10 type vaultFactory struct { 11 sr SecretReader 12 prefix string 13 sharedPath string 14 lookupTemplates []*creds.SecretTemplate 15 loggedIn <-chan struct{} 16 } 17 18 func NewVaultFactory(sr SecretReader, loggedIn <-chan struct{}, prefix string, lookupTemplates []*creds.SecretTemplate, sharedPath string) *vaultFactory { 19 factory := &vaultFactory{ 20 sr: sr, 21 prefix: prefix, 22 lookupTemplates: lookupTemplates, 23 sharedPath: sharedPath, 24 loggedIn: loggedIn, 25 } 26 27 return factory 28 } 29 30 // NewSecrets will block until the loggedIn channel passed to the constructor signals a successful login. 31 func (factory *vaultFactory) NewSecrets() creds.Secrets { 32 select { 33 case <-factory.loggedIn: 34 case <-time.After(5 * time.Second): 35 } 36 37 return &Vault{ 38 SecretReader: factory.sr, 39 Prefix: factory.prefix, 40 LookupTemplates: factory.lookupTemplates, 41 SharedPath: factory.sharedPath, 42 } 43 }