File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ func (c *Config) LoadConfig(file string) error {
75
75
return err
76
76
}
77
77
78
+ data = []byte (expandEnv (string (data )))
79
+
78
80
err = yaml .Unmarshal (data , & c )
79
81
if err != nil {
80
82
return err
@@ -83,6 +85,13 @@ func (c *Config) LoadConfig(file string) error {
83
85
return nil
84
86
}
85
87
88
+ // expandEnv replaces all environment variables in the provided string. The environment variables can be in the form
89
+ // `${var}` or `$var`. If the string should contain a `$` it can be escaped via `$$`.
90
+ func expandEnv (s string ) string {
91
+ os .Setenv ("CRANE_DOLLAR" , "$" )
92
+ return os .ExpandEnv (strings .Replace (s , "$$" , "${CRANE_DOLLAR}" , - 1 ))
93
+ }
94
+
86
95
// ValidateConfig validates no contradictory config options are set.
87
96
func ValidateConfig (c Config ) []error {
88
97
var errs []error
You can’t perform that action at this time.
0 commit comments