github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/atc/creds/conjur/conjur.go (about) 1 package conjur 2 3 import ( 4 "time" 5 6 "code.cloudfoundry.org/lager" 7 "github.com/pf-qiu/concourse/v6/atc/creds" 8 ) 9 10 type IConjurClient interface { 11 RetrieveSecret(string) ([]byte, error) 12 } 13 14 type Conjur struct { 15 log lager.Logger 16 client IConjurClient 17 secretTemplates []*creds.SecretTemplate 18 } 19 20 func NewConjur(log lager.Logger, client IConjurClient, secretTemplates []*creds.SecretTemplate) *Conjur { 21 return &Conjur{ 22 log: log, 23 client: client, 24 secretTemplates: secretTemplates, 25 } 26 } 27 28 func (c Conjur) NewSecretLookupPaths(teamName string, pipelineName string, allowRootPath bool) []creds.SecretLookupPath { 29 lookupPaths := []creds.SecretLookupPath{} 30 for _, template := range c.secretTemplates { 31 c.log.Info(" teamname: " + teamName + "pipeline: " + pipelineName) 32 if lPath := creds.NewSecretLookupWithTemplate(template, teamName, pipelineName); lPath != nil { 33 lookupPaths = append(lookupPaths, lPath) 34 } 35 } 36 37 return lookupPaths 38 } 39 40 func (c Conjur) Get(secretPath string) (interface{}, *time.Time, bool, error) { 41 secretValue, err := c.client.RetrieveSecret(secretPath) 42 if err != nil { 43 return nil, nil, false, nil 44 } 45 return string(secretValue), nil, true, nil 46 }