yaml2: Meta should keep defaults, and Res should have kind

This would previously panic since it wouldn't get a kind, and the meta
parameters would overwrite the defaults so it would block because limit
didn't have the default of +inf.

The removal of the SetKind was my fault in:

b8ff6938df

It's funny because it ends in `bad`. Guess I should have checked that!
This commit is contained in:
James Shubin
2017-09-06 13:39:11 -04:00
parent 653c76709a
commit 71ab325940

View File

@@ -54,7 +54,6 @@ type Edge struct {
// ResourceData are the parameters for resource format.
type ResourceData struct {
Name string `yaml:"name"`
Meta resources.MetaParams `yaml:"meta"`
}
// Resource is the object that unmarshalls resources.
@@ -132,10 +131,10 @@ func (r *Resource) Decode(kind string) (err error) {
return err
}
// Set resource name, meta and kind
// set resource name and kind
r.resource.SetName(r.Name)
meta := r.resource.Meta()
*meta = r.Meta
r.resource.SetKind(strings.ToLower(kind)) // gets overwritten, so set it
// meta already gets unmarshalled properly with the correct defaults
return
}