forked from concourse/concourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
secrets.go
42 lines (31 loc) · 1002 Bytes
/
secrets.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
package dummy
import (
"path"
"time"
"github.com/pf-qiu/concourse/v6/atc/creds"
"github.com/pf-qiu/concourse/v6/vars"
)
type Secrets struct {
vars.StaticVariables
TeamName string
PipelineName string
}
func (secrets *Secrets) NewSecretLookupPaths(teamName string, pipelineName string, allowRootPath bool) []creds.SecretLookupPath {
lookupPaths := []creds.SecretLookupPath{}
if len(pipelineName) > 0 {
lookupPaths = append(lookupPaths, creds.NewSecretLookupWithPrefix(path.Join(teamName, pipelineName)+"/"))
}
lookupPaths = append(lookupPaths, creds.NewSecretLookupWithPrefix(teamName+"/"))
lookupPaths = append(lookupPaths, creds.NewSecretLookupWithPrefix(""))
return lookupPaths
}
func (secrets *Secrets) Get(secretPath string) (interface{}, *time.Time, bool, error) {
v, found, err := secrets.StaticVariables.Get(vars.Reference{Path: secretPath})
if err != nil {
return nil, nil, false, err
}
if found {
return v, nil, true, nil
}
return nil, nil, false, nil
}