diff --git a/coreos-cloudinit.go b/coreos-cloudinit.go index 79d4c15..8c55202 100644 --- a/coreos-cloudinit.go +++ b/coreos-cloudinit.go @@ -89,7 +89,7 @@ func main() { } } - env := initialize.NewEnvironment("/", workspace) + env := initialize.NewEnvironment("/", workspace, sshKeyName) if len(userdataBytes) > 0 { if err := processUserdata(string(userdataBytes), env); err != nil { fmt.Printf("Failed resolving user-data: %v\n", err) diff --git a/initialize/env.go b/initialize/env.go index 7460c2d..b0ab3c1 100644 --- a/initialize/env.go +++ b/initialize/env.go @@ -15,12 +15,12 @@ type Environment struct { substitutions map[string]string } -func NewEnvironment(root, workspace string) *Environment { +func NewEnvironment(root, workspace, sshKeyName string) *Environment { substitutions := map[string]string{ "$public_ipv4": os.Getenv("COREOS_PUBLIC_IPV4"), "$private_ipv4": os.Getenv("COREOS_PRIVATE_IPV4"), } - return &Environment{root, workspace, DefaultSSHKeyName, substitutions} + return &Environment{root, workspace, sshKeyName, substitutions} } func (self *Environment) Workspace() string { diff --git a/initialize/env_test.go b/initialize/env_test.go index 432663b..f10a054 100644 --- a/initialize/env_test.go +++ b/initialize/env_test.go @@ -8,7 +8,7 @@ import ( func TestEnvironmentApply(t *testing.T) { os.Setenv("COREOS_PUBLIC_IPV4", "192.0.2.3") os.Setenv("COREOS_PRIVATE_IPV4", "192.0.2.203") - env := NewEnvironment("./", "./") + env := NewEnvironment("./", "./", "") input := `[Service] ExecStart=/usr/bin/echo "$public_ipv4" ExecStop=/usr/bin/echo $private_ipv4