aboutsummaryrefslogtreecommitdiffstats
path: root/src/kube2msb/vendor/gopkg.in/yaml.v2/decode.go
diff options
context:
space:
mode:
authorHuabingZhao <zhao.huabing@zte.com.cn>2017-10-18 03:25:50 +0000
committerHuabingZhao <zhao.huabing@zte.com.cn>2017-10-18 22:41:11 +0800
commite3e197dba342c76cb05aa16652682094020d8abf (patch)
tree97cbadfaaba08de782b774ae641741c997e65630 /src/kube2msb/vendor/gopkg.in/yaml.v2/decode.go
parentb6ccf74fe168b2add28c83c79d07c9758239440d (diff)
Update the yaml for go lib to latest
Update yaml for go lib to latest and it's license has been changed to Apache 2. According to the upstream project, the license of go-yaml has been updated to Apache 2:https://github.com/go-yaml/yaml/blob/v2/LICENSE, change the reference code license within oom-registrator repo accordingly. Issue-Id: OOM-365 Change-Id: Idce4bfda96456031a296682b0fb6e663170ec099 Signed-off-by: HuabingZhao <zhao.huabing@zte.com.cn>
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