mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #2756 from liggitt/yaml_bump
Bump yaml, test full int64 serialization
This commit is contained in:
commit
2261c3e71c
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -160,7 +160,7 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "gopkg.in/v2/yaml",
|
||||
"Rev": "8fac37523b5c7a1128bf0217f6bd07be1ad266b2"
|
||||
"Rev": "d466437aa4adc35830964cffc5b5f262c63ddcb4"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
59
Godeps/_workspace/src/gopkg.in/v2/yaml/decode.go
generated
vendored
59
Godeps/_workspace/src/gopkg.in/v2/yaml/decode.go
generated
vendored
@ -4,8 +4,8 @@ import (
|
||||
"encoding"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@ -32,9 +32,9 @@ type node struct {
|
||||
// Parser, produces a node tree out of a libyaml event stream.
|
||||
|
||||
type parser struct {
|
||||
parser yaml_parser_t
|
||||
event yaml_event_t
|
||||
doc *node
|
||||
parser yaml_parser_t
|
||||
event yaml_event_t
|
||||
doc *node
|
||||
}
|
||||
|
||||
func newParser(b []byte) *parser {
|
||||
@ -194,10 +194,10 @@ type decoder struct {
|
||||
}
|
||||
|
||||
var (
|
||||
mapItemType = reflect.TypeOf(MapItem{})
|
||||
durationType = reflect.TypeOf(time.Duration(0))
|
||||
mapItemType = reflect.TypeOf(MapItem{})
|
||||
durationType = reflect.TypeOf(time.Duration(0))
|
||||
defaultMapType = reflect.TypeOf(map[interface{}]interface{}{})
|
||||
ifaceType = defaultMapType.Elem()
|
||||
ifaceType = defaultMapType.Elem()
|
||||
)
|
||||
|
||||
func newDecoder() *decoder {
|
||||
@ -207,7 +207,6 @@ func newDecoder() *decoder {
|
||||
}
|
||||
|
||||
func (d *decoder) terror(n *node, tag string, out reflect.Value) {
|
||||
debug.PrintStack()
|
||||
if n.tag != "" {
|
||||
tag = n.tag
|
||||
}
|
||||
@ -252,20 +251,13 @@ func (d *decoder) callUnmarshaler(n *node, u Unmarshaler) (good bool) {
|
||||
//
|
||||
// If n holds a null value, prepare returns before doing anything.
|
||||
func (d *decoder) prepare(n *node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) {
|
||||
//fmt.Printf("yv2 prepare: out.Kind(): %s\n", out.Kind())
|
||||
//fmt.Printf("yv2 prepare: n.tag: %s\n", n.tag)
|
||||
//fmt.Printf("yv2 prepare: n.value: %s\n", n.value)
|
||||
//fmt.Printf("yv2 prepare: n.kind: %s\n", n.kind)
|
||||
if (n.tag == yaml_NULL_TAG) || (n.kind == scalarNode && n.tag == "" && (n.value == "" && n.implicit)) {
|
||||
//fmt.Printf("yv2 prepare: return immediately\n")
|
||||
if n.tag == yaml_NULL_TAG || n.kind == scalarNode && n.tag == "" && (n.value == "null" || n.value == "") {
|
||||
return out, false, false
|
||||
}
|
||||
//fmt.Printf("yv2 prepare: continue\n")
|
||||
again := true
|
||||
for again {
|
||||
again = false
|
||||
if out.Kind() == reflect.Ptr {
|
||||
//fmt.Printf("yv2 prepare: hit Ptr %s\n", out.Kind())
|
||||
if out.IsNil() {
|
||||
out.Set(reflect.New(out.Type().Elem()))
|
||||
}
|
||||
@ -338,18 +330,12 @@ func resetMap(out reflect.Value) {
|
||||
}
|
||||
|
||||
func (d *decoder) scalar(n *node, out reflect.Value) (good bool) {
|
||||
//fmt.Printf("yv2 1 tag: %s, implicit: %v, out.Type(): %s\n", n.tag, n.implicit, out.Type())
|
||||
//fmt.Printf("yv2 n.value: %v\n", n.value)
|
||||
//fmt.Printf("yv2 n.kind: %v\n", n.kind)
|
||||
//fmt.Printf("yv2 n.tag: %v\n", n.tag)
|
||||
var tag string
|
||||
var resolved interface{}
|
||||
if n.tag == "" && !n.implicit {
|
||||
//fmt.Printf("yv2 2\n")
|
||||
tag = yaml_STR_TAG
|
||||
resolved = n.value
|
||||
} else {
|
||||
//fmt.Printf("yv2 3\n")
|
||||
tag, resolved = resolve(n.tag, n.value)
|
||||
if tag == yaml_BINARY_TAG {
|
||||
data, err := base64.StdEncoding.DecodeString(resolved.(string))
|
||||
@ -359,9 +345,7 @@ func (d *decoder) scalar(n *node, out reflect.Value) (good bool) {
|
||||
resolved = string(data)
|
||||
}
|
||||
}
|
||||
//fmt.Printf("yv2 4\n")
|
||||
if resolved == nil {
|
||||
//fmt.Printf("yv2 5\n")
|
||||
if out.Kind() == reflect.Map && !out.CanAddr() {
|
||||
resetMap(out)
|
||||
} else {
|
||||
@ -370,7 +354,6 @@ func (d *decoder) scalar(n *node, out reflect.Value) (good bool) {
|
||||
return true
|
||||
}
|
||||
if s, ok := resolved.(string); ok && out.CanAddr() {
|
||||
//fmt.Printf("yv2 6")
|
||||
if u, ok := out.Addr().Interface().(encoding.TextUnmarshaler); ok {
|
||||
err := u.UnmarshalText([]byte(s))
|
||||
if err != nil {
|
||||
@ -379,9 +362,6 @@ func (d *decoder) scalar(n *node, out reflect.Value) (good bool) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
//fmt.Printf("yv2 resolved tag: %v\n", tag)
|
||||
//fmt.Printf("yv2 resolved: %v\n", resolved)
|
||||
//fmt.Printf("yv2 resolved type: %v\n", reflect.TypeOf(resolved))
|
||||
switch out.Kind() {
|
||||
case reflect.String:
|
||||
if tag == yaml_BINARY_TAG {
|
||||
@ -410,8 +390,13 @@ func (d *decoder) scalar(n *node, out reflect.Value) (good bool) {
|
||||
out.SetInt(resolved)
|
||||
good = true
|
||||
}
|
||||
case uint64:
|
||||
if resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) {
|
||||
out.SetInt(int64(resolved))
|
||||
good = true
|
||||
}
|
||||
case float64:
|
||||
if resolved < 1<<63-1 && !out.OverflowInt(int64(resolved)) {
|
||||
if resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) {
|
||||
out.SetInt(int64(resolved))
|
||||
good = true
|
||||
}
|
||||
@ -427,17 +412,22 @@ func (d *decoder) scalar(n *node, out reflect.Value) (good bool) {
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
switch resolved := resolved.(type) {
|
||||
case int:
|
||||
if resolved >= 0 {
|
||||
if resolved >= 0 && !out.OverflowUint(uint64(resolved)) {
|
||||
out.SetUint(uint64(resolved))
|
||||
good = true
|
||||
}
|
||||
case int64:
|
||||
if resolved >= 0 {
|
||||
if resolved >= 0 && !out.OverflowUint(uint64(resolved)) {
|
||||
out.SetUint(uint64(resolved))
|
||||
good = true
|
||||
}
|
||||
case uint64:
|
||||
if !out.OverflowUint(uint64(resolved)) {
|
||||
out.SetUint(uint64(resolved))
|
||||
good = true
|
||||
}
|
||||
case float64:
|
||||
if resolved < 1<<64-1 && !out.OverflowUint(uint64(resolved)) {
|
||||
if resolved <= math.MaxUint64 && !out.OverflowUint(uint64(resolved)) {
|
||||
out.SetUint(uint64(resolved))
|
||||
good = true
|
||||
}
|
||||
@ -456,6 +446,9 @@ func (d *decoder) scalar(n *node, out reflect.Value) (good bool) {
|
||||
case int64:
|
||||
out.SetFloat(float64(resolved))
|
||||
good = true
|
||||
case uint64:
|
||||
out.SetFloat(float64(resolved))
|
||||
good = true
|
||||
case float64:
|
||||
out.SetFloat(resolved)
|
||||
good = true
|
||||
@ -510,6 +503,8 @@ func (d *decoder) sequence(n *node, out reflect.Value) (good bool) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (d *decoder) mapping(n *node, out reflect.Value) (good bool) {
|
||||
switch out.Kind() {
|
||||
case reflect.Struct:
|
||||
|
178
Godeps/_workspace/src/gopkg.in/v2/yaml/decode_test.go
generated
vendored
178
Godeps/_workspace/src/gopkg.in/v2/yaml/decode_test.go
generated
vendored
@ -2,16 +2,13 @@ package yaml_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
. "gopkg.in/check.v1"
|
||||
"gopkg.in/yaml.v2"
|
||||
"math"
|
||||
"net"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
. "gopkg.in/check.v1"
|
||||
"gopkg.in/v2/yaml"
|
||||
)
|
||||
|
||||
var unmarshalIntTest = 123
|
||||
@ -270,6 +267,114 @@ var unmarshalTests = []struct {
|
||||
map[string]uint64{},
|
||||
},
|
||||
|
||||
// int
|
||||
{
|
||||
"int_max: 2147483647",
|
||||
map[string]int{"int_max": math.MaxInt32},
|
||||
},
|
||||
{
|
||||
"int_min: -2147483648",
|
||||
map[string]int{"int_min": math.MinInt32},
|
||||
},
|
||||
{
|
||||
"int_overflow: 9223372036854775808", // math.MaxInt64 + 1
|
||||
map[string]int{},
|
||||
},
|
||||
|
||||
// int64
|
||||
{
|
||||
"int64_max: 9223372036854775807",
|
||||
map[string]int64{"int64_max": math.MaxInt64},
|
||||
},
|
||||
{
|
||||
"int64_max_base2: 0b111111111111111111111111111111111111111111111111111111111111111",
|
||||
map[string]int64{"int64_max_base2": math.MaxInt64},
|
||||
},
|
||||
{
|
||||
"int64_min: -9223372036854775808",
|
||||
map[string]int64{"int64_min": math.MinInt64},
|
||||
},
|
||||
{
|
||||
"int64_neg_base2: -0b111111111111111111111111111111111111111111111111111111111111111",
|
||||
map[string]int64{"int64_neg_base2": -math.MaxInt64},
|
||||
},
|
||||
{
|
||||
"int64_overflow: 9223372036854775808", // math.MaxInt64 + 1
|
||||
map[string]int64{},
|
||||
},
|
||||
|
||||
// uint
|
||||
{
|
||||
"uint_min: 0",
|
||||
map[string]uint{"uint_min": 0},
|
||||
},
|
||||
{
|
||||
"uint_max: 4294967295",
|
||||
map[string]uint{"uint_max": math.MaxUint32},
|
||||
},
|
||||
{
|
||||
"uint_underflow: -1",
|
||||
map[string]uint{},
|
||||
},
|
||||
|
||||
// uint64
|
||||
{
|
||||
"uint64_min: 0",
|
||||
map[string]uint{"uint64_min": 0},
|
||||
},
|
||||
{
|
||||
"uint64_max: 18446744073709551615",
|
||||
map[string]uint64{"uint64_max": math.MaxUint64},
|
||||
},
|
||||
{
|
||||
"uint64_max_base2: 0b1111111111111111111111111111111111111111111111111111111111111111",
|
||||
map[string]uint64{"uint64_max_base2": math.MaxUint64},
|
||||
},
|
||||
{
|
||||
"uint64_maxint64: 9223372036854775807",
|
||||
map[string]uint64{"uint64_maxint64": math.MaxInt64},
|
||||
},
|
||||
{
|
||||
"uint64_underflow: -1",
|
||||
map[string]uint64{},
|
||||
},
|
||||
|
||||
// float32
|
||||
{
|
||||
"float32_max: 3.40282346638528859811704183484516925440e+38",
|
||||
map[string]float32{"float32_max": math.MaxFloat32},
|
||||
},
|
||||
{
|
||||
"float32_nonzero: 1.401298464324817070923729583289916131280e-45",
|
||||
map[string]float32{"float32_nonzero": math.SmallestNonzeroFloat32},
|
||||
},
|
||||
{
|
||||
"float32_maxuint64: 18446744073709551615",
|
||||
map[string]float32{"float32_maxuint64": float32(math.MaxUint64)},
|
||||
},
|
||||
{
|
||||
"float32_maxuint64+1: 18446744073709551616",
|
||||
map[string]float32{"float32_maxuint64+1": float32(math.MaxUint64 + 1)},
|
||||
},
|
||||
|
||||
// float64
|
||||
{
|
||||
"float64_max: 1.797693134862315708145274237317043567981e+308",
|
||||
map[string]float64{"float64_max": math.MaxFloat64},
|
||||
},
|
||||
{
|
||||
"float64_nonzero: 4.940656458412465441765687928682213723651e-324",
|
||||
map[string]float64{"float64_nonzero": math.SmallestNonzeroFloat64},
|
||||
},
|
||||
{
|
||||
"float64_maxuint64: 18446744073709551615",
|
||||
map[string]float64{"float64_maxuint64": float64(math.MaxUint64)},
|
||||
},
|
||||
{
|
||||
"float64_maxuint64+1: 18446744073709551616",
|
||||
map[string]float64{"float64_maxuint64+1": float64(math.MaxUint64 + 1)},
|
||||
},
|
||||
|
||||
// Overflow cases.
|
||||
{
|
||||
"v: 4294967297",
|
||||
@ -462,13 +567,7 @@ func (s *S) TestUnmarshal(c *C) {
|
||||
if t.Kind() == reflect.String {
|
||||
c.Assert(*value.(*string), Equals, item.value)
|
||||
} else {
|
||||
if !c.Check(value, DeepEquals, item.value) {
|
||||
fmt.Printf("Spew:\n")
|
||||
spew.Dump(item.data)
|
||||
spew.Dump(item.value)
|
||||
spew.Dump(value)
|
||||
return
|
||||
}
|
||||
c.Assert(value, DeepEquals, item.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -773,61 +872,6 @@ func (s *S) TestUnmarshalNull(c *C) {
|
||||
}
|
||||
}
|
||||
|
||||
type StringStructContainer struct {
|
||||
Val StringStruct
|
||||
}
|
||||
|
||||
type StringStruct struct {
|
||||
StrVal string
|
||||
UnmarshalCalled bool // to be able to check that UnmarshalYAML was actually called
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
||||
func (s *StringStruct) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var value *string
|
||||
if err := unmarshal(&value); err != nil {
|
||||
return err
|
||||
}
|
||||
s.StrVal = *value
|
||||
s.UnmarshalCalled = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// If a node value is a literal empty string (i.e.: "") but the corresponding
|
||||
// object to Unmarshal to is a struct or a pointer to a struct, the struct must
|
||||
// have UnmarshalYAML() called on it with an empty string.
|
||||
func (s *S) TestUnmarshalEmptyStringToStruct(c *C) {
|
||||
//j := []byte(`{"val": "null"}`)
|
||||
// Literal empty string should call UnmarshalYAML.
|
||||
j := []byte("val: \"\"\n")
|
||||
v := new(StringStructContainer)
|
||||
err := yaml.Unmarshal(j, v)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(v.Val.StrVal, Equals, "")
|
||||
c.Assert(v.Val.UnmarshalCalled, Equals, true)
|
||||
}
|
||||
|
||||
func (s *S) TestUnmarshalNullStringToStruct(c *C) {
|
||||
// "null" string should not call UnmarshalYAML, but instead produce a zero object.
|
||||
j := []byte("val: null\n")
|
||||
v := new(StringStructContainer)
|
||||
err := yaml.Unmarshal(j, v)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(v.Val.StrVal, Equals, "")
|
||||
c.Assert(v.Val.UnmarshalCalled, Equals, false)
|
||||
}
|
||||
|
||||
// "Implicit" document ending should not call UnmarshalYAML, but instead produce a blank object.
|
||||
func (s *S) TestUnmarshalImplicitEndingToStruct(c *C) {
|
||||
// "null" string should not call UnmarshalYAML, but instead produce a zero object.
|
||||
j := []byte("val: \n")
|
||||
v := new(StringStructContainer)
|
||||
err := yaml.Unmarshal(j, v)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(v.Val.StrVal, Equals, "")
|
||||
c.Assert(v.Val.UnmarshalCalled, Equals, false)
|
||||
}
|
||||
|
||||
//var data []byte
|
||||
//func init() {
|
||||
// var err error
|
||||
|
20
Godeps/_workspace/src/gopkg.in/v2/yaml/encode.go
generated
vendored
20
Godeps/_workspace/src/gopkg.in/v2/yaml/encode.go
generated
vendored
@ -63,11 +63,8 @@ func (e *encoder) marshal(tag string, in reflect.Value) {
|
||||
e.nilv()
|
||||
return
|
||||
}
|
||||
//fmt.Printf("marshal 1 in: %s\n", in)
|
||||
iface := in.Interface()
|
||||
//fmt.Printf("marshal 1 iface: %s\n", iface)
|
||||
if m, ok := iface.(Marshaler); ok {
|
||||
//fmt.Printf("marshal 1 calling MarshalYAML\n")
|
||||
v, err := m.MarshalYAML()
|
||||
if err != nil {
|
||||
fail(err)
|
||||
@ -77,20 +74,16 @@ func (e *encoder) marshal(tag string, in reflect.Value) {
|
||||
return
|
||||
}
|
||||
in = reflect.ValueOf(v)
|
||||
} else if m, ok := iface.(encoding.TextMarshaler); ok {
|
||||
}
|
||||
if m, ok := iface.(encoding.TextMarshaler); ok {
|
||||
text, err := m.MarshalText()
|
||||
if err != nil {
|
||||
fail(err)
|
||||
}
|
||||
in = reflect.ValueOf(string(text))
|
||||
}
|
||||
//fmt.Printf("marshal 2 in: %s\n", in)
|
||||
//fmt.Printf("marshal 2 in string: %s\n", in.String())
|
||||
//fmt.Printf("marshal 2 in Kind: %s\n", in.Kind())
|
||||
//fmt.Printf("marshal 2.5 in Kind: %s\n", in.Kind())
|
||||
switch in.Kind() {
|
||||
case reflect.Interface:
|
||||
//fmt.Printf("marshal 3\n")
|
||||
if in.IsNil() {
|
||||
e.nilv()
|
||||
} else {
|
||||
@ -99,14 +92,12 @@ func (e *encoder) marshal(tag string, in reflect.Value) {
|
||||
case reflect.Map:
|
||||
e.mapv(tag, in)
|
||||
case reflect.Ptr:
|
||||
//fmt.Printf("marshal 4\n")
|
||||
if in.IsNil() {
|
||||
e.nilv()
|
||||
} else {
|
||||
e.marshal(tag, in.Elem())
|
||||
}
|
||||
case reflect.Struct:
|
||||
//fmt.Printf("marshal 5\n")
|
||||
e.structv(tag, in)
|
||||
case reflect.Slice:
|
||||
if in.Type().Elem() == mapItemType {
|
||||
@ -115,7 +106,6 @@ func (e *encoder) marshal(tag string, in reflect.Value) {
|
||||
e.slicev(tag, in)
|
||||
}
|
||||
case reflect.String:
|
||||
//fmt.Printf("marshal 6 in.String: \n", in.String())
|
||||
e.stringv(tag, in)
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
if in.Type() == durationType {
|
||||
@ -173,7 +163,6 @@ func (e *encoder) structv(tag string, in reflect.Value) {
|
||||
}
|
||||
e.marshal("", reflect.ValueOf(info.Key))
|
||||
e.flow = info.Flow
|
||||
//fmt.Printf("structv mappingv value: %s\n", value)
|
||||
e.marshal("", value)
|
||||
}
|
||||
})
|
||||
@ -233,17 +222,13 @@ func isBase60Float(s string) (result bool) {
|
||||
var base60float = regexp.MustCompile(`^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+(?:\.[0-9_]*)?$`)
|
||||
|
||||
func (e *encoder) stringv(tag string, in reflect.Value) {
|
||||
//fmt.Printf("stringv 1\n")
|
||||
var style yaml_scalar_style_t
|
||||
s := in.String()
|
||||
//fmt.Printf("stringv 1 s: %s\n", s)
|
||||
rtag, rs := resolve("", s)
|
||||
if rtag == yaml_BINARY_TAG {
|
||||
//fmt.Printf("stringv 2\n")
|
||||
if tag == "" || tag == yaml_STR_TAG {
|
||||
tag = rtag
|
||||
s = rs.(string)
|
||||
//fmt.Printf("stringv 3 s: %s\n", s)
|
||||
} else if tag == yaml_BINARY_TAG {
|
||||
failf("explicitly tagged !!binary data must be base64-encoded")
|
||||
} else {
|
||||
@ -257,7 +242,6 @@ func (e *encoder) stringv(tag string, in reflect.Value) {
|
||||
} else {
|
||||
style = yaml_PLAIN_SCALAR_STYLE
|
||||
}
|
||||
//fmt.Printf("stringv 4 style: %s\n", style)
|
||||
e.emitScalar(s, "", tag, style)
|
||||
}
|
||||
|
||||
|
21
Godeps/_workspace/src/gopkg.in/v2/yaml/resolve.go
generated
vendored
21
Godeps/_workspace/src/gopkg.in/v2/yaml/resolve.go
generated
vendored
@ -81,7 +81,6 @@ func resolvableTag(tag string) bool {
|
||||
}
|
||||
|
||||
func resolve(tag string, in string) (rtag string, out interface{}) {
|
||||
//fmt.Printf("yv2 resolve tag: %s, in: %s\n", tag, in)
|
||||
if !resolvableTag(tag) {
|
||||
return tag, in
|
||||
}
|
||||
@ -132,6 +131,10 @@ func resolve(tag string, in string) (rtag string, out interface{}) {
|
||||
return yaml_INT_TAG, intv
|
||||
}
|
||||
}
|
||||
uintv, err := strconv.ParseUint(plain, 0, 64)
|
||||
if err == nil {
|
||||
return yaml_INT_TAG, uintv
|
||||
}
|
||||
floatv, err := strconv.ParseFloat(plain, 64)
|
||||
if err == nil {
|
||||
return yaml_FLOAT_TAG, floatv
|
||||
@ -139,12 +142,24 @@ func resolve(tag string, in string) (rtag string, out interface{}) {
|
||||
if strings.HasPrefix(plain, "0b") {
|
||||
intv, err := strconv.ParseInt(plain[2:], 2, 64)
|
||||
if err == nil {
|
||||
return yaml_INT_TAG, int(intv)
|
||||
if intv == int64(int(intv)) {
|
||||
return yaml_INT_TAG, int(intv)
|
||||
} else {
|
||||
return yaml_INT_TAG, intv
|
||||
}
|
||||
}
|
||||
uintv, err := strconv.ParseUint(plain[2:], 2, 64)
|
||||
if err == nil {
|
||||
return yaml_INT_TAG, uintv
|
||||
}
|
||||
} else if strings.HasPrefix(plain, "-0b") {
|
||||
intv, err := strconv.ParseInt(plain[3:], 2, 64)
|
||||
if err == nil {
|
||||
return yaml_INT_TAG, -int(intv)
|
||||
if intv == int64(int(intv)) {
|
||||
return yaml_INT_TAG, -int(intv)
|
||||
} else {
|
||||
return yaml_INT_TAG, -intv
|
||||
}
|
||||
}
|
||||
}
|
||||
// XXX Handle timestamps here.
|
||||
|
@ -40,10 +40,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
},
|
||||
func(j *internal.ObjectMeta, c fuzz.Continue) {
|
||||
j.Name = c.RandString()
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
|
||||
j.SelfLink = c.RandString()
|
||||
|
||||
var sec, nsec int64
|
||||
@ -52,10 +49,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
j.CreationTimestamp = util.Unix(sec, nsec).Rfc3339Copy()
|
||||
},
|
||||
func(j *internal.ListMeta, c fuzz.Continue) {
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
|
||||
j.SelfLink = c.RandString()
|
||||
},
|
||||
func(j *internal.ObjectReference, c fuzz.Continue) {
|
||||
@ -65,10 +59,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
j.Kind = c.RandString()
|
||||
j.Namespace = c.RandString()
|
||||
j.Name = c.RandString()
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
|
||||
j.FieldPath = c.RandString()
|
||||
},
|
||||
func(j *internal.PodPhase, c fuzz.Continue) {
|
||||
@ -104,10 +95,6 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
intstr.StrVal = c.RandString()
|
||||
}
|
||||
},
|
||||
func(u64 *uint64, c fuzz.Continue) {
|
||||
// TODO: uint64's are NOT handled right.
|
||||
*u64 = c.RandUint64() >> 8
|
||||
},
|
||||
func(pb map[docker.Port][]docker.PortBinding, c fuzz.Continue) {
|
||||
// This is necessary because keys with nil values get omitted.
|
||||
// TODO: Is this a bug?
|
||||
|
@ -50,10 +50,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
j.Kind = ""
|
||||
|
||||
j.Name = c.RandString()
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
|
||||
j.SelfLink = c.RandString()
|
||||
|
||||
var sec, nsec int64
|
||||
@ -69,10 +66,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
},
|
||||
func(j *api.ObjectMeta, c fuzz.Continue) {
|
||||
j.Name = c.RandString()
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
|
||||
j.SelfLink = c.RandString()
|
||||
|
||||
var sec, nsec int64
|
||||
@ -81,10 +75,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
j.CreationTimestamp = util.Unix(sec, nsec).Rfc3339Copy()
|
||||
},
|
||||
func(j *api.ListMeta, c fuzz.Continue) {
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
|
||||
j.SelfLink = c.RandString()
|
||||
},
|
||||
func(j *api.PodPhase, c fuzz.Continue) {
|
||||
@ -120,10 +111,6 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
intstr.StrVal = c.RandString()
|
||||
}
|
||||
},
|
||||
func(u64 *uint64, c fuzz.Continue) {
|
||||
// TODO: uint64's are NOT handled right.
|
||||
*u64 = c.RandUint64() >> 8
|
||||
},
|
||||
func(pb map[docker.Port][]docker.PortBinding, c fuzz.Continue) {
|
||||
// This is necessary because keys with nil values get omitted.
|
||||
// TODO: Is this a bug?
|
||||
|
@ -51,10 +51,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
j.Kind = ""
|
||||
|
||||
j.Name = c.RandString()
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
|
||||
j.SelfLink = c.RandString()
|
||||
|
||||
var sec, nsec int64
|
||||
@ -70,10 +67,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
},
|
||||
func(j *api.ObjectMeta, c fuzz.Continue) {
|
||||
j.Name = c.RandString()
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
|
||||
j.SelfLink = c.RandString()
|
||||
|
||||
var sec, nsec int64
|
||||
@ -82,10 +76,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
j.CreationTimestamp = util.Unix(sec, nsec).Rfc3339Copy()
|
||||
},
|
||||
func(j *api.ListMeta, c fuzz.Continue) {
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
|
||||
j.SelfLink = c.RandString()
|
||||
},
|
||||
func(j *api.PodPhase, c fuzz.Continue) {
|
||||
@ -121,10 +112,6 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
intstr.StrVal = c.RandString()
|
||||
}
|
||||
},
|
||||
func(u64 *uint64, c fuzz.Continue) {
|
||||
// TODO: uint64's are NOT handled right.
|
||||
*u64 = c.RandUint64() >> 8
|
||||
},
|
||||
func(pb map[docker.Port][]docker.PortBinding, c fuzz.Continue) {
|
||||
// This is necessary because keys with nil values get omitted.
|
||||
// TODO: Is this a bug?
|
||||
|
@ -104,18 +104,6 @@ var TestObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 100).Funcs(
|
||||
j.ObjectKind = ""
|
||||
j.ID = c.RandString()
|
||||
},
|
||||
func(u *uint64, c fuzz.Continue) {
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
*u = c.RandUint64() >> 8
|
||||
},
|
||||
func(u *uint, c fuzz.Continue) {
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
*u = uint(c.RandUint64() >> 8)
|
||||
},
|
||||
)
|
||||
|
||||
// Returns a new Scheme set up with the test objects.
|
||||
|
Loading…
Reference in New Issue
Block a user