yaml: replace goyaml with yaml

This commit is contained in:
Alex Crawford 2014-09-08 13:25:27 -07:00
parent c5b3788282
commit 78aa2c56ec
2 changed files with 11 additions and 11 deletions

View File

@ -6,7 +6,7 @@ import (
"log" "log"
"path" "path"
"github.com/coreos/coreos-cloudinit/third_party/launchpad.net/goyaml" "github.com/coreos/coreos-cloudinit/third_party/gopkg.in/yaml.v1"
"github.com/coreos/coreos-cloudinit/network" "github.com/coreos/coreos-cloudinit/network"
"github.com/coreos/coreos-cloudinit/system" "github.com/coreos/coreos-cloudinit/system"
@ -51,12 +51,12 @@ type warner func(format string, v ...interface{})
func warnOnUnrecognizedKeys(contents string, warn warner) { func warnOnUnrecognizedKeys(contents string, warn warner) {
// Generate a map of all understood cloud config options // Generate a map of all understood cloud config options
var cc map[string]interface{} var cc map[string]interface{}
b, _ := goyaml.Marshal(&CloudConfig{}) b, _ := yaml.Marshal(&CloudConfig{})
goyaml.Unmarshal(b, &cc) yaml.Unmarshal(b, &cc)
// Now unmarshal the entire provided contents // Now unmarshal the entire provided contents
var c map[string]interface{} var c map[string]interface{}
goyaml.Unmarshal([]byte(contents), &c) yaml.Unmarshal([]byte(contents), &c)
// Check that every key in the contents exists in the cloud config // Check that every key in the contents exists in the cloud config
for k, _ := range c { for k, _ := range c {
@ -84,8 +84,8 @@ func warnOnUnrecognizedKeys(contents string, warn warner) {
// Check for any badly-specified users, if any are set // Check for any badly-specified users, if any are set
if users, ok := c["users"]; ok { if users, ok := c["users"]; ok {
var known map[string]interface{} var known map[string]interface{}
b, _ := goyaml.Marshal(&system.User{}) b, _ := yaml.Marshal(&system.User{})
goyaml.Unmarshal(b, &known) yaml.Unmarshal(b, &known)
if set, ok := users.([]interface{}); ok { if set, ok := users.([]interface{}); ok {
for _, u := range set { for _, u := range set {
@ -107,8 +107,8 @@ func warnOnUnrecognizedKeys(contents string, warn warner) {
// Check for any badly-specified files, if any are set // Check for any badly-specified files, if any are set
if files, ok := c["write_files"]; ok { if files, ok := c["write_files"]; ok {
var known map[string]interface{} var known map[string]interface{}
b, _ := goyaml.Marshal(&system.File{}) b, _ := yaml.Marshal(&system.File{})
goyaml.Unmarshal(b, &known) yaml.Unmarshal(b, &known)
if set, ok := files.([]interface{}); ok { if set, ok := files.([]interface{}); ok {
for _, f := range set { for _, f := range set {
@ -133,7 +133,7 @@ func warnOnUnrecognizedKeys(contents string, warn warner) {
// fields but log encountering them. // fields but log encountering them.
func NewCloudConfig(contents string) (*CloudConfig, error) { func NewCloudConfig(contents string) (*CloudConfig, error) {
var cfg CloudConfig var cfg CloudConfig
err := goyaml.Unmarshal([]byte(contents), &cfg) err := yaml.Unmarshal([]byte(contents), &cfg)
if err != nil { if err != nil {
return &cfg, err return &cfg, err
} }
@ -142,7 +142,7 @@ func NewCloudConfig(contents string) (*CloudConfig, error) {
} }
func (cc CloudConfig) String() string { func (cc CloudConfig) String() string {
bytes, err := goyaml.Marshal(cc) bytes, err := yaml.Marshal(cc)
if err != nil { if err != nil {
return "" return ""
} }

View File

@ -16,7 +16,7 @@ func ParseUserData(contents string) (interface{}, error) {
// Explicitly trim the header so we can handle user-data from // Explicitly trim the header so we can handle user-data from
// non-unix operating systems. The rest of the file is parsed // non-unix operating systems. The rest of the file is parsed
// by goyaml, which correctly handles CRLF. // by yaml, which correctly handles CRLF.
header = strings.TrimSpace(header) header = strings.TrimSpace(header)
if strings.HasPrefix(header, "#!") { if strings.HasPrefix(header, "#!") {