|
|
|
|
@ -16,14 +16,18 @@ func init() {
|
|
|
|
|
varRegexp = regexp.MustCompile(`(?i)(\$+)\{([-.a-z0-9_]+)\}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// replaceVariables takes a configuration and a mapping of variables
|
|
|
|
|
// ReplaceVariables takes a configuration and a mapping of variables
|
|
|
|
|
// and performs the structure walking necessary to properly replace
|
|
|
|
|
// all the variables.
|
|
|
|
|
func replaceVariables(
|
|
|
|
|
c map[string]interface{},
|
|
|
|
|
vs map[string]string) error {
|
|
|
|
|
func ReplaceVariables(
|
|
|
|
|
c interface{},
|
|
|
|
|
vs map[string]string) ([]string, error) {
|
|
|
|
|
w := &variableReplaceWalker{Values: vs}
|
|
|
|
|
return reflectwalk.Walk(c, w)
|
|
|
|
|
if err := reflectwalk.Walk(c, w); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return w.UnknownKeys, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// variableDetectWalker implements interfaces for the reflectwalk package
|
|
|
|
|
|