mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
commit
3dd7c4481b
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -103,7 +103,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/ghodss/yaml",
|
"ImportPath": "github.com/ghodss/yaml",
|
||||||
"Rev": "3bc1590d16074751993dd3b1a76e7a8d1a916a11"
|
"Rev": "588cb435e59ee8b6c2795482887755841ad67207"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/golang/glog",
|
"ImportPath": "github.com/golang/glog",
|
||||||
|
7
Godeps/_workspace/src/github.com/ghodss/yaml/yaml.go
generated
vendored
7
Godeps/_workspace/src/github.com/ghodss/yaml/yaml.go
generated
vendored
@ -46,7 +46,12 @@ func Unmarshal(y []byte, o interface{}) error {
|
|||||||
func JSONToYAML(j []byte) ([]byte, error) {
|
func JSONToYAML(j []byte) ([]byte, error) {
|
||||||
// Convert the JSON to an object.
|
// Convert the JSON to an object.
|
||||||
var jsonObj interface{}
|
var jsonObj interface{}
|
||||||
err := json.Unmarshal(j, &jsonObj)
|
// We are using yaml.Unmarshal here (instead of json.Unmarshal) because the
|
||||||
|
// Go JSON library doesn't try to pick the right number type (int, float,
|
||||||
|
// etc.) when unmarshling to interface{}, it just picks float64
|
||||||
|
// universally. go-yaml does go through the effort of picking the right
|
||||||
|
// number type, so we can preserve number type throughout this process.
|
||||||
|
err := yaml.Unmarshal(j, &jsonObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
12
Godeps/_workspace/src/github.com/ghodss/yaml/yaml_test.go
generated
vendored
12
Godeps/_workspace/src/github.com/ghodss/yaml/yaml_test.go
generated
vendored
@ -1,17 +1,25 @@
|
|||||||
package yaml
|
package yaml
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MarshalTest struct {
|
type MarshalTest struct {
|
||||||
A string
|
A string
|
||||||
|
B int64
|
||||||
|
// Would like to test float64, but it's not supported in go-yaml.
|
||||||
|
// (See https://github.com/go-yaml/yaml/issues/83.)
|
||||||
|
C float32
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMarshal(t *testing.T) {
|
func TestMarshal(t *testing.T) {
|
||||||
s := MarshalTest{"a"}
|
f32String := strconv.FormatFloat(math.MaxFloat32, 'g', -1, 32)
|
||||||
e := []byte("A: a\n")
|
s := MarshalTest{"a", math.MaxInt64, math.MaxFloat32}
|
||||||
|
e := []byte(fmt.Sprintf("A: a\nB: %d\nC: %s\n", math.MaxInt64, f32String))
|
||||||
|
|
||||||
y, err := Marshal(s)
|
y, err := Marshal(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user