aboutsummaryrefslogtreecommitdiffstats
path: root/src/kube2msb/vendor/gopkg.in/yaml.v2/decode.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/kube2msb/vendor/gopkg.in/yaml.v2/decode.go')
-rw-r--r--src/kube2msb/vendor/gopkg.in/yaml.v2/decode.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/kube2msb/vendor/gopkg.in/yaml.v2/decode.go b/src/kube2msb/vendor/gopkg.in/yaml.v2/decode.go
index 085cddc..db1f5f2 100644
--- a/src/kube2msb/vendor/gopkg.in/yaml.v2/decode.go
+++ b/src/kube2msb/vendor/gopkg.in/yaml.v2/decode.go
@@ -120,7 +120,6 @@ func (p *parser) parse() *node {
default:
panic("attempted to parse unknown event: " + strconv.Itoa(int(p.event.typ)))
}
- panic("unreachable")
}
func (p *parser) node(kind int) *node {
@@ -191,6 +190,7 @@ type decoder struct {
aliases map[string]bool
mapType reflect.Type
terrors []string
+ strict bool
}
var (
@@ -200,8 +200,8 @@ var (
ifaceType = defaultMapType.Elem()
)
-func newDecoder() *decoder {
- d := &decoder{mapType: defaultMapType}
+func newDecoder(strict bool) *decoder {
+ d := &decoder{mapType: defaultMapType, strict: strict}
d.aliases = make(map[string]bool)
return d
}
@@ -251,7 +251,7 @@ 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) {
- if n.tag == yaml_NULL_TAG || n.kind == scalarNode && n.tag == "" && (n.value == "null" || n.value == "") {
+ if n.tag == yaml_NULL_TAG || n.kind == scalarNode && n.tag == "" && (n.value == "null" || n.value == "" && n.implicit) {
return out, false, false
}
again := true
@@ -640,6 +640,8 @@ func (d *decoder) mappingStruct(n *node, out reflect.Value) (good bool) {
value := reflect.New(elemType).Elem()
d.unmarshal(n.children[i+1], value)
inlineMap.SetMapIndex(name, value)
+ } else if d.strict {
+ d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s not found in struct %s", n.line+1, name.String(), out.Type()))
}
}
return true