fix(etcd): fix runtime panic when etcd section is missing.

The etcd code tries to assign ee["name"] even when the map was never
defined and assigning to an uninitialized map causes a panic.
This commit is contained in:
Michael Marineau
2014-05-16 20:27:50 -07:00
parent f83ce07416
commit ea6262f0ae
2 changed files with 16 additions and 0 deletions

View File

@@ -31,6 +31,10 @@ func (ee EtcdEnvironment) String() (out string) {
// Unit creates a Unit file drop-in for etcd, using any configured
// options and adding a default MachineID if unset.
func (ee EtcdEnvironment) Unit(root string) (*system.Unit, error) {
if ee == nil {
return nil, nil
}
if _, ok := ee["name"]; !ok {
if machineID := system.MachineID(root); machineID != "" {
ee["name"] = machineID