diff --git a/initialize/config.go b/initialize/config.go index 752a21a..7755924 100644 --- a/initialize/config.go +++ b/initialize/config.go @@ -22,7 +22,7 @@ type CloudConfigFile interface { // CloudConfigUnit represents a CoreOS specific configuration option that can generate // associated system.Units to be created/enabled appropriately type CloudConfigUnit interface { - Units() ([]system.Unit, error) + Units() []system.Unit } // Apply renders a CloudConfig to an Environment. This can involve things like @@ -117,11 +117,7 @@ func Apply(cfg config.CloudConfig, env *Environment) error { system.Fleet{cfg.Coreos.Fleet}, system.Update{cfg.Coreos.Update, system.DefaultReadConfig}, } { - u, err := ccu.Units() - if err != nil { - return err - } - units = append(units, u...) + units = append(units, ccu.Units()...) } wroteEnvironment := false diff --git a/system/etcd.go b/system/etcd.go index dd7664f..95cbf6a 100644 --- a/system/etcd.go +++ b/system/etcd.go @@ -11,15 +11,15 @@ type Etcd struct { } // Units creates a Unit file drop-in for etcd, using any configured options. -func (ee Etcd) Units() ([]Unit, error) { +func (ee Etcd) Units() []Unit { content := dropinContents(ee.Etcd) if content == "" { - return nil, nil + return nil } return []Unit{{config.Unit{ Name: "etcd.service", Runtime: true, DropIn: true, Content: content, - }}}, nil + }}} } diff --git a/system/etcd_test.go b/system/etcd_test.go index 2e65768..a626333 100644 --- a/system/etcd_test.go +++ b/system/etcd_test.go @@ -49,10 +49,7 @@ Environment="ETCD_PEER_BIND_ADDR=127.0.0.1:7002" }}}, }, } { - units, err := Etcd{tt.config}.Units() - if err != nil { - t.Errorf("bad error (%q): want %q, got %q", tt.config, nil, err) - } + units := Etcd{tt.config}.Units() if !reflect.DeepEqual(tt.units, units) { t.Errorf("bad units (%q): want %#v, got %#v", tt.config, tt.units, units) } diff --git a/system/fleet.go b/system/fleet.go index a4ce127..cf21ba2 100644 --- a/system/fleet.go +++ b/system/fleet.go @@ -12,15 +12,15 @@ type Fleet struct { // Units generates a Unit file drop-in for fleet, if any fleet options were // configured in cloud-config -func (fe Fleet) Units() ([]Unit, error) { +func (fe Fleet) Units() []Unit { content := dropinContents(fe.Fleet) if content == "" { - return nil, nil + return nil } return []Unit{{config.Unit{ Name: "fleet.service", Runtime: true, DropIn: true, Content: content, - }}}, nil + }}} } diff --git a/system/fleet_test.go b/system/fleet_test.go index 48e52f9..3715a5c 100644 --- a/system/fleet_test.go +++ b/system/fleet_test.go @@ -30,10 +30,7 @@ Environment="FLEET_PUBLIC_IP=12.34.56.78" }}}, }, } { - units, err := Fleet{tt.config}.Units() - if err != nil { - t.Errorf("bad error (%q): want %q, got %q", tt.config, nil, err) - } + units := Fleet{tt.config}.Units() if !reflect.DeepEqual(units, tt.units) { t.Errorf("bad units (%q): want %q, got %q", tt.config, tt.units, units) } diff --git a/system/update.go b/system/update.go index 7f98dfe..14c6aa7 100644 --- a/system/update.go +++ b/system/update.go @@ -100,7 +100,7 @@ func (uc Update) File() (*File, error) { // Units generates units for the cloud-init initializer to act on: // - a locksmith Unit, if "reboot-strategy" was set in cloud-config // - an update_engine Unit, if "group" or "server" was set in cloud-config -func (uc Update) Units() ([]Unit, error) { +func (uc Update) Units() []Unit { var units []Unit if uc.Config.RebootStrategy != "" { ls := &Unit{config.Unit{ @@ -125,7 +125,7 @@ func (uc Update) Units() ([]Unit, error) { units = append(units, ue) } - return units, nil + return units } func sortedKeys(m map[string]string) (keys []string) { diff --git a/system/update_test.go b/system/update_test.go index 2ff95d2..25bc75c 100644 --- a/system/update_test.go +++ b/system/update_test.go @@ -66,10 +66,7 @@ func TestUpdateUnits(t *testing.T) { }}}, }, } { - units, err := Update{tt.config, testReadConfig("")}.Units() - if !reflect.DeepEqual(tt.err, err) { - t.Errorf("bad error (%q): want %q, got %q", tt.config, tt.err, err) - } + units := Update{tt.config, testReadConfig("")}.Units() if !reflect.DeepEqual(tt.units, units) { t.Errorf("bad units (%q): want %#v, got %#v", tt.config, tt.units, units) }