all: migration from gopkg.in/yaml.v1 to gopkg.in/yaml.v2 #3490

Merged
merged 2 commits into from Oct 14, 2015
Jump to file or symbol
Failed to load files and symbols.
+99 −117
Split
View
@@ -10,7 +10,7 @@ import (
"strconv"
"github.com/juju/names"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/version"
View
@@ -10,7 +10,7 @@ import (
"github.com/juju/errors"
"github.com/juju/names"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/state/multiwatcher"
@@ -657,7 +657,7 @@ func (context *statusContext) processUnit(unit *state.Unit, serviceCharm string)
// Usually this indicates that no addresses have been set on the
// machine yet.
addr = network.Address{}
- logger.Warningf("error fetching public address: %q", err)
+ logger.Warningf("error fetching public address: %v", err)
}
result.PublicAddress = addr.Value
unitPorts, _ := unit.OpenedPorts()
@@ -11,7 +11,7 @@ import (
"github.com/juju/utils/packaging"
"github.com/juju/utils/packaging/config"
"github.com/juju/utils/proxy"
- "gopkg.in/yaml.v1"
+ "gopkg.in/yaml.v2"
)
// centOSCloudConfig is the cloudconfig type specific to CentOS machines.
@@ -12,7 +12,7 @@ import (
"github.com/juju/utils/packaging"
"github.com/juju/utils/packaging/config"
"github.com/juju/utils/proxy"
- "gopkg.in/yaml.v1"
+ "gopkg.in/yaml.v2"
)
// ubuntuCloudConfig is the cloudconfig type specific to Ubuntu machines
@@ -11,7 +11,7 @@ import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
- "gopkg.in/yaml.v1"
+ "gopkg.in/yaml.v2"
"github.com/juju/juju/cloudconfig/cloudinit"
"github.com/juju/juju/cloudconfig/containerinit"
@@ -14,7 +14,7 @@ import (
jc "github.com/juju/testing/checkers"
"github.com/juju/utils"
gc "gopkg.in/check.v1"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/agent"
"github.com/juju/juju/api"
@@ -17,7 +17,7 @@ import (
pacconf "github.com/juju/utils/packaging/config"
"github.com/juju/utils/set"
gc "gopkg.in/check.v1"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/agent"
"github.com/juju/juju/api"
@@ -22,7 +22,7 @@ import (
"github.com/juju/utils/os"
"github.com/juju/utils/proxy"
"github.com/juju/utils/series"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/cloudconfig/cloudinit"
"github.com/juju/juju/environs/config"
@@ -8,7 +8,7 @@ import (
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/names"
- "gopkg.in/yaml.v1"
+ "gopkg.in/yaml.v2"
"github.com/juju/juju/apiserver/params"
)
@@ -12,7 +12,7 @@ import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"gopkg.in/juju/charm.v6-unstable"
- "gopkg.in/yaml.v1"
+ "gopkg.in/yaml.v2"
"github.com/juju/juju/cmd/juju/action"
"github.com/juju/juju/state"
View
@@ -11,7 +11,7 @@ import (
"github.com/juju/cmd"
"github.com/juju/errors"
"github.com/juju/names"
- yaml "gopkg.in/yaml.v1"
+ yaml "gopkg.in/yaml.v2"
"launchpad.net/gnuflag"
"github.com/juju/juju/apiserver/params"
@@ -13,7 +13,7 @@ import (
jc "github.com/juju/testing/checkers"
"github.com/juju/utils"
gc "gopkg.in/check.v1"
- "gopkg.in/yaml.v1"
+ "gopkg.in/yaml.v2"
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/apiserver/params"
@@ -232,17 +232,17 @@ func (s *DoSuite) TestRun(c *gc.C) {
withArgs: []string{validUnitId, "some-action",
"--params", s.dir + "/" + "invalidParams.yml",
},
- expectedErr: "YAML error: line 3: mapping values are not allowed in this context",
+ expectedErr: "yaml: line 3: mapping values are not allowed in this context",
}, {
should: "fail with invalid UTF in file",
withArgs: []string{validUnitId, "some-action",
"--params", s.dir + "/" + "invalidUTF.yml",
},
- expectedErr: "YAML error: invalid leading UTF-8 octet",
+ expectedErr: "yaml: invalid leading UTF-8 octet",
}, {
should: "fail with invalid YAML passed as arg and no --string-args",
withArgs: []string{validUnitId, "some-action", "foo.bar=\""},
- expectedErr: "YAML error: found unexpected end of stream",
+ expectedErr: "yaml: found unexpected end of stream",
}, {
should: "enqueue a basic action with no params",
withArgs: []string{validUnitId, "some-action"},
@@ -12,7 +12,7 @@ import (
"github.com/juju/cmd"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/apiserver/common"
"github.com/juju/juju/apiserver/params"
@@ -10,7 +10,7 @@ import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"gopkg.in/juju/charm.v6-unstable"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/cmd/envcmd"
"github.com/juju/juju/juju/testing"
@@ -12,7 +12,7 @@ import (
"github.com/juju/cmd"
"github.com/juju/errors"
"github.com/juju/names"
- "gopkg.in/yaml.v1"
+ "gopkg.in/yaml.v2"
"github.com/juju/juju/cmd/envcmd"
"github.com/juju/juju/environs/configstore"
@@ -12,7 +12,7 @@ import (
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
- "gopkg.in/yaml.v1"
+ "gopkg.in/yaml.v2"
"github.com/juju/juju/cmd/envcmd"
"github.com/juju/juju/cmd/juju/environment"
@@ -97,7 +97,7 @@ var jenvFileContentErrorsTests = []struct {
}, {
about: "invalid YAML",
contents: []byte(":"),
- err: "invalid jenv file .*: cannot unmarshal jenv data: YAML error: .*",
+ err: "invalid jenv file .*: cannot unmarshal jenv data: yaml: .*",
}, {
about: "missing field",
contents: makeJenvContents("myuser", "mypasswd", "env-uuid", "", "1.2.3.4:17070"),
@@ -9,7 +9,7 @@ import (
"github.com/juju/cmd"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/cmd/envcmd"
"github.com/juju/juju/cmd/juju/service"
@@ -16,7 +16,7 @@ import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"gopkg.in/juju/charm.v6-unstable"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/cmd/envcmd"
@@ -10,7 +10,7 @@ import (
"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/cmd/envcmd"
@@ -11,7 +11,7 @@ import (
"github.com/juju/cmd"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/cmd/envcmd"
@@ -11,7 +11,7 @@ import (
"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/cmd/envcmd"
@@ -12,7 +12,7 @@ import (
"github.com/juju/errors"
"github.com/juju/names"
"github.com/juju/utils/keyvalues"
- "gopkg.in/yaml.v1"
+ "gopkg.in/yaml.v2"
"launchpad.net/gnuflag"
"github.com/juju/juju/apiserver/params"
@@ -13,7 +13,7 @@ import (
jc "github.com/juju/testing/checkers"
"github.com/juju/utils"
gc "gopkg.in/check.v1"
- "gopkg.in/yaml.v1"
+ "gopkg.in/yaml.v2"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/cmd/envcmd"
@@ -234,7 +234,7 @@ func (s *createSuite) TestConfigFileFormatError(c *gc.C) {
file.Close()
_, err = s.run(c, "test", "--config", file.Name())
- c.Assert(err, gc.ErrorMatches, `unable to parse config file: YAML error: .*`)
+ c.Assert(err, gc.ErrorMatches, `unable to parse config file: yaml: .*`)
}
func (s *createSuite) TestConfigFileDoesntExist(c *gc.C) {
@@ -8,7 +8,7 @@ import (
"github.com/juju/errors"
"github.com/juju/names"
"github.com/juju/utils"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"launchpad.net/gnuflag"
"github.com/juju/juju/api"
@@ -109,7 +109,7 @@ func (s *LoginSuite) TestBadServerFile(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
_, err = s.run(c, "foo", "--server", serverFilePath)
- c.Assert(err, gc.ErrorMatches, "YAML error: did not find expected alphabetic or numeric character")
+ c.Assert(err, gc.ErrorMatches, "yaml: did not find expected alphabetic or numeric character")
}
func (s *LoginSuite) TestBadUser(c *gc.C) {
@@ -9,7 +9,7 @@ import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/cmd/envcmd"
"github.com/juju/juju/cmd/juju/user"
View
@@ -20,7 +20,7 @@ import (
"github.com/juju/names"
"github.com/juju/utils"
"github.com/juju/utils/series"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"launchpad.net/gnuflag"
"github.com/juju/juju/agent"
@@ -23,7 +23,7 @@ import (
"github.com/juju/utils/set"
gc "gopkg.in/check.v1"
"gopkg.in/mgo.v2"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/agent"
agenttools "github.com/juju/juju/agent/tools"
@@ -21,7 +21,7 @@ import (
"github.com/juju/loggo"
"github.com/juju/names"
"github.com/juju/utils"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"launchpad.net/gnuflag"
"github.com/juju/juju/api"
@@ -431,19 +431,19 @@ func (v *Value) setRaw(raw string) error {
return nil
}
-// SetYAML is required to unmarshall a constraints.Value object
+// UnmarshalYAML is required to unmarshal a constraints.Value object
// to ensure the container attribute is correctly handled when it is empty.
// Because ContainerType is an alias for string, Go's reflect logic used in the
// YAML decode determines that *string and *ContainerType are not assignable so
// the container value of "" in the YAML is ignored.
-func (v *Value) SetYAML(tag string, value interface{}) bool {
- values, ok := value.(map[interface{}]interface{})
- if !ok {
- return false
+func (v *Value) UnmarshalYAML(unmarshal func(interface{}) error) error {
+ values := map[interface{}]interface{}{}
+ err := unmarshal(&values)
+ if err != nil {
+ return errors.Trace(err)
}
for k, val := range values {
vstr := fmt.Sprintf("%v", val)
- var err error
switch k {
case Arch:
v.Arch = &vstr
@@ -466,7 +466,7 @@ func (v *Value) SetYAML(tag string, value interface{}) bool {
var spaces *[]string
spaces, err = parseYamlStrings("spaces", val)
if err != nil {
- return false
+ return errors.Trace(err)
}
err = v.validateSpaces(spaces)
if err == nil {
@@ -476,20 +476,20 @@ func (v *Value) SetYAML(tag string, value interface{}) bool {
var networks *[]string
networks, err = parseYamlStrings("networks", val)
if err != nil {
- return false
+ return errors.Trace(err)
}
err = v.validateNetworks(networks)
if err == nil {
v.Networks = networks
}
default:
- return false
+ return errors.Errorf("unknown constraint value: %v", k)
}
if err != nil {
- return false
+ return errors.Trace(err)
}
}
- return true
+ return nil
}
func (v *Value) setContainer(str string) error {
@@ -11,7 +11,7 @@ import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"github.com/juju/juju/constraints"
"github.com/juju/juju/instance"
@@ -20,7 +20,7 @@ import (
"github.com/juju/utils/set"
"github.com/juju/utils/symlink"
gc "gopkg.in/check.v1"
- goyaml "gopkg.in/yaml.v1"
+ goyaml "gopkg.in/yaml.v2"
"launchpad.net/golxc"
"github.com/juju/juju/agent"
View
@@ -50,6 +50,7 @@ gopkg.in/mgo.v2 git 3569c88678d88179dcbd68d02ab081cbca3cd4d0 2015-06-04T15:26:27
gopkg.in/natefinch/lumberjack.v2 git 588a21fb0fa0ebdfde42670fa214576b6f0f22df 2015-05-21T01:59:18Z
gopkg.in/natefinch/npipe.v2 git e562d4ae5c2f838f9e7e406f7d9890d5b02467a9 2014-08-11T16:19:00Z
gopkg.in/yaml.v1 git 9f9df34309c04878acc86042b16630b0f696e1de 2014-09-24T16:16:07Z
+gopkg.in/yaml.v2 git 7ad95dd0798a40da1ccdff6dff35fd177b5edf40 2015-06-24T10:29:02Z
launchpad.net/gnuflag bzr roger.peppe@canonical.com-20140716064605-pk32dnmfust02yab 13
launchpad.net/golxc bzr ian.booth@canonical.com-20141121040613-ztm1q0iy9rune3zt 13
launchpad.net/gomaasapi bzr michael.foord@canonical.com-20150703101140-oo7493pkzlzg7l6u 63
Oops, something went wrong.