refactor(env): Add the config root and netconf type to datasource and env

This commit is contained in:
Alex Crawford
2014-06-18 11:36:06 -07:00
parent 259c7e1fe2
commit 29ed6b38bd
8 changed files with 44 additions and 13 deletions

View File

@@ -10,17 +10,19 @@ const DefaultSSHKeyName = "coreos-cloudinit"
type Environment struct {
root string
configRoot string
workspace string
netconfType string
sshKeyName string
substitutions map[string]string
}
func NewEnvironment(root, workspace, sshKeyName string) *Environment {
func NewEnvironment(root, configRoot, workspace, netconfType, 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, sshKeyName, substitutions}
return &Environment{root, configRoot, workspace, netconfType, sshKeyName, substitutions}
}
func (self *Environment) Workspace() string {
@@ -31,6 +33,14 @@ func (self *Environment) Root() string {
return self.root
}
func (self *Environment) ConfigRoot() string {
return self.configRoot
}
func (self *Environment) NetconfType() string {
return self.netconfType
}
func (self *Environment) SSHKeyName() string {
return self.sshKeyName
}

View File

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