Merge pull request #200 from jonboulle/fu
initialize: use correct heuristic to check if etcdenvironment is set
This commit is contained in:
commit
c428ce2cc5
@ -39,7 +39,7 @@ func (ee EtcdEnvironment) String() (out string) {
|
|||||||
// Units creates a Unit file drop-in for etcd, using any configured
|
// Units creates a Unit file drop-in for etcd, using any configured
|
||||||
// options and adding a default MachineID if unset.
|
// options and adding a default MachineID if unset.
|
||||||
func (ee EtcdEnvironment) Units(root string) ([]system.Unit, error) {
|
func (ee EtcdEnvironment) Units(root string) ([]system.Unit, error) {
|
||||||
if ee == nil {
|
if len(ee) < 1 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,8 +113,19 @@ Environment="ETCD_PEER_BIND_ADDR=127.0.0.1:7002"
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEtcdEnvironmentWrittenToDiskDefaultToMachineID(t *testing.T) {
|
func TestEtcdEnvironmentEmptyNoOp(t *testing.T) {
|
||||||
ee := EtcdEnvironment{}
|
ee := EtcdEnvironment{}
|
||||||
|
uu, err := ee.Units("")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if len(uu) > 0 {
|
||||||
|
t.Fatalf("Generated etcd units unexpectedly: %v")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEtcdEnvironmentWrittenToDiskDefaultToMachineID(t *testing.T) {
|
||||||
|
ee := EtcdEnvironment{"foo": "bar"}
|
||||||
dir, err := ioutil.TempDir(os.TempDir(), "coreos-cloudinit-")
|
dir, err := ioutil.TempDir(os.TempDir(), "coreos-cloudinit-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to create tempdir: %v", err)
|
t.Fatalf("Unable to create tempdir: %v", err)
|
||||||
@ -152,6 +163,7 @@ func TestEtcdEnvironmentWrittenToDiskDefaultToMachineID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expect := `[Service]
|
expect := `[Service]
|
||||||
|
Environment="ETCD_FOO=bar"
|
||||||
Environment="ETCD_NAME=node007"
|
Environment="ETCD_NAME=node007"
|
||||||
`
|
`
|
||||||
if string(contents) != expect {
|
if string(contents) != expect {
|
||||||
|
Loading…
Reference in New Issue
Block a user