github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/atc/creds/dummy/secrets.go (about) 1 package dummy 2 3 import ( 4 "path" 5 "time" 6 7 "github.com/pf-qiu/concourse/v6/atc/creds" 8 "github.com/pf-qiu/concourse/v6/vars" 9 ) 10 11 type Secrets struct { 12 vars.StaticVariables 13 14 TeamName string 15 PipelineName string 16 } 17 18 func (secrets *Secrets) NewSecretLookupPaths(teamName string, pipelineName string, allowRootPath bool) []creds.SecretLookupPath { 19 lookupPaths := []creds.SecretLookupPath{} 20 21 if len(pipelineName) > 0 { 22 lookupPaths = append(lookupPaths, creds.NewSecretLookupWithPrefix(path.Join(teamName, pipelineName)+"/")) 23 } 24 25 lookupPaths = append(lookupPaths, creds.NewSecretLookupWithPrefix(teamName+"/")) 26 lookupPaths = append(lookupPaths, creds.NewSecretLookupWithPrefix("")) 27 28 return lookupPaths 29 } 30 31 func (secrets *Secrets) Get(secretPath string) (interface{}, *time.Time, bool, error) { 32 v, found, err := secrets.StaticVariables.Get(vars.Reference{Path: secretPath}) 33 if err != nil { 34 return nil, nil, false, err 35 } 36 37 if found { 38 return v, nil, true, nil 39 } 40 41 return nil, nil, false, nil 42 }