← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/juju-core/remove-serializeYAML into lp:~maas-maintainers/juju-core/maas-provider-skeleton

 

Raphaël Badin has proposed merging lp:~rvb/juju-core/remove-serializeYAML into lp:~maas-maintainers/juju-core/maas-provider-skeleton.

Commit message:
Ditch machineInfo.serializeYAML()

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~rvb/juju-core/remove-serializeYAML/+merge/158305

fwreade 25

Drive-by fix: remove unused import in environs/maas/environ_test.go (was breaking the build)
-- 
https://code.launchpad.net/~rvb/juju-core/remove-serializeYAML/+merge/158305
Your team MAAS Maintainers is requested to review the proposed merge of lp:~rvb/juju-core/remove-serializeYAML into lp:~maas-maintainers/juju-core/maas-provider-skeleton.
=== modified file 'environs/maas/environ_test.go'
--- environs/maas/environ_test.go	2013-04-11 08:58:29 +0000
+++ environs/maas/environ_test.go	2013-04-11 09:36:20 +0000
@@ -1,7 +1,6 @@
 package maas
 
 import (
-	"bytes"
 	"encoding/base64"
 	"fmt"
 	. "launchpad.net/gocheck"

=== modified file 'environs/maas/environprovider_test.go'
--- environs/maas/environprovider_test.go	2013-04-11 00:04:51 +0000
+++ environs/maas/environprovider_test.go	2013-04-11 09:36:20 +0000
@@ -3,6 +3,7 @@
 import (
 	"io/ioutil"
 	. "launchpad.net/gocheck"
+	"launchpad.net/goyaml"
 	"launchpad.net/juju-core/environs/config"
 	"launchpad.net/juju-core/state"
 	"os"
@@ -51,7 +52,7 @@
 func (suite *EnvironProviderSuite) TestInstanceIdReadsInstanceIdFromMachineFile(c *C) {
 	instanceId := "instance-id"
 	info := machineInfo{instanceId, "hostname"}
-	yaml, err := info.serializeYAML()
+	yaml, err := goyaml.Marshal(info)
 	c.Assert(err, IsNil)
 	// Create a temporary file to act as the file where the instanceID
 	// is stored.
@@ -74,7 +75,7 @@
 func (suite *EnvironProviderSuite) TestPrivatePublicAddressReadsHostnameFromMachineFile(c *C) {
 	hostname := "myhostname"
 	info := machineInfo{"instance-id", hostname}
-	yaml, err := info.serializeYAML()
+	yaml, err := goyaml.Marshal(info)
 	c.Assert(err, IsNil)
 	// Create a temporary file to act as the file where the instanceID
 	// is stored.

=== modified file 'environs/maas/util.go'
--- environs/maas/util.go	2013-04-10 13:51:53 +0000
+++ environs/maas/util.go	2013-04-11 09:36:20 +0000
@@ -64,16 +64,11 @@
 
 var _MAASInstanceFilename = jujuDataDir + "/MAASmachine.txt"
 
-// serializeYAML serializes the info into YAML format.
-func (info *machineInfo) serializeYAML() ([]byte, error) {
-	return goyaml.Marshal(info)
-}
-
 // cloudinitRunCmd returns the shell command that, when run, will create the
 // "machine info" file containing the instanceId and the hostname of a machine.
 // That command is destined to be used by cloudinit.
 func (info *machineInfo) cloudinitRunCmd() (string, error) {
-	yaml, err := info.serializeYAML()
+	yaml, err := goyaml.Marshal(info)
 	if err != nil {
 		return "", err
 	}

=== modified file 'environs/maas/util_test.go'
--- environs/maas/util_test.go	2013-04-11 08:14:50 +0000
+++ environs/maas/util_test.go	2013-04-11 09:36:20 +0000
@@ -94,18 +94,6 @@
 	c.Check(runCmd[1], Equals, script2)
 }
 
-func (s *UtilSuite) TestMachineInfoserializeYAML(c *C) {
-	instanceId := "instanceId"
-	hostname := "hostname"
-	info := machineInfo{instanceId, hostname}
-
-	yaml, err := info.serializeYAML()
-
-	c.Assert(err, IsNil)
-	expected := "instanceid: instanceId\nhostname: hostname\n"
-	c.Check(string(yaml), Equals, expected)
-}
-
 func (s *UtilSuite) TestMachineInfoCloudinitRunCmd(c *C) {
 	instanceId := "instanceId"
 	hostname := "hostname"
@@ -118,7 +106,7 @@
 	script, err := info.cloudinitRunCmd()
 
 	c.Assert(err, IsNil)
-	yaml, err := info.serializeYAML()
+	yaml, err := goyaml.Marshal(info)
 	c.Assert(err, IsNil)
 	expected := fmt.Sprintf("mkdir -p '%s'; echo -n '%s' > '%s'", jujuDataDir, yaml, filename)
 	c.Check(script, Equals, expected)