initialize/env: handle nil substitution maps properly

This commit is contained in:
Jonathan Boulle 2014-06-25 12:07:48 -07:00
parent bda3948382
commit f0dba2294e
2 changed files with 9 additions and 0 deletions

View File

@ -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"),

View File

@ -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)