1package dummy
2
3import (
4	"path"
5	"time"
6
7	"github.com/concourse/concourse/atc/creds"
8	"github.com/concourse/concourse/vars"
9)
10
11type Secrets struct {
12	vars.StaticVariables
13
14	TeamName     string
15	PipelineName string
16}
17
18func (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
31func (secrets *Secrets) Get(secretPath string) (interface{}, *time.Time, bool, error) {
32	v, found, err := secrets.StaticVariables.Get(vars.VariableDefinition{
33		Ref: vars.VariableReference{Path: secretPath},
34	})
35	if err != nil {
36		return nil, nil, false, err
37	}
38
39	if found {
40		return v, nil, true, nil
41	}
42
43	return nil, nil, false, nil
44}
45