refactor(env): Add the config root and netconf type to datasource and env
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user