initialize/env: handle nil substitution maps properly
This commit is contained in:
parent
bda3948382
commit
f0dba2294e
@ -19,6 +19,9 @@ type Environment struct {
|
||||
|
||||
// TODO(jonboulle): this is getting unwieldy, should be able to simplify the interface somehow
|
||||
func NewEnvironment(root, configRoot, workspace, netconfType, sshKeyName string, substitutions map[string]string) *Environment {
|
||||
if substitutions == nil {
|
||||
substitutions = make(map[string]string)
|
||||
}
|
||||
// If certain values are not in the supplied substitution, fall back to retrieving them from the environment
|
||||
for k, v := range map[string]string{
|
||||
"$public_ipv4": os.Getenv("COREOS_PUBLIC_IPV4"),
|
||||
|
@ -41,6 +41,12 @@ ExecStop=/usr/bin/echo $unknown`,
|
||||
"$private_ipv4\n$public_ipv4",
|
||||
"5.6.7.8\n1.2.3.4",
|
||||
},
|
||||
{
|
||||
// No substitutions
|
||||
nil,
|
||||
"$private_ipv4\nfoobar",
|
||||
"5.6.7.8\nfoobar",
|
||||
},
|
||||
} {
|
||||
|
||||
env := NewEnvironment("./", "./", "./", "", "", tt.subs)
|
||||
|
Loading…
Reference in New Issue
Block a user