-
Notifications
You must be signed in to change notification settings - Fork 4
/
variable_source.go
35 lines (32 loc) · 1.15 KB
/
variable_source.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
package varsource
import "context"
// VariableSource represents the necessary functionality of a source of variables.
type VariableSource interface {
// GetVariables takes a map of variable-name to variable-definition
// and returns a map of variable-name to variable-value. i.e. returns
// the same map except that the variable definitions are replaced with
// the actual variable values.
//
// For example:
// {
// "DB_USERNAME": "from:env:DB_USERNAME",
// "DB_PASSWORD": "from:file:~/.creds/password.txt",
// }
// would be translated to:
// {
// "DB_USERNAME": "database-user-xyz",
// "DB_PASSWORD": "df29^%qd3gs8&*&(asd8t\tqe=",
// }
GetVariables(ctx context.Context, vars map[string]string) (map[string]string, error)
GetVariable(ctx context.Context, varDefn string) (string, error)
}
// NewDefaultVariableSource returns the default VariableSource implementation.
func NewDefaultVariableSource() VariableSource {
return NewMultipleUpstreamVariableSource(
WithTopLevelPrefix(defaultTopLevelPrefix),
WithEnvVariableUpstream(),
WithFileVariableUpstream(),
WithAWSSSMVariableUpstream(),
WithAWSSecretsManagerVariableUpstream(),
)
}