diff --git a/initialize/env.go b/initialize/env.go index 4161898..2019c3e 100644 --- a/initialize/env.go +++ b/initialize/env.go @@ -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"), diff --git a/initialize/env_test.go b/initialize/env_test.go index 756c957..b48ae21 100644 --- a/initialize/env_test.go +++ b/initialize/env_test.go @@ -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)