Commit a8ebc131 authored by Dr. Stefan Schimanski's avatar Dr. Stefan Schimanski Committed by Dr. Stefan Schimanski

Workaround ugorji/go/codecs regression

parent 0301487d
......@@ -27,8 +27,9 @@ package v1
import (
"fmt"
"strings"
"github.com/ugorji/go/codec"
)
// TypeMeta describes an individual object in an API response or request
......@@ -422,6 +423,27 @@ func (vs Verbs) String() string {
return fmt.Sprintf("%v", []string(vs))
}
// CodecEncodeSelf is part of the codec.Selfer interface.
func (vs *Verbs) CodecEncodeSelf(encoder *codec.Encoder) {
encoder.Encode(vs)
}
// CodecDecodeSelf is part of the codec.Selfer interface. It is overwritten here to make sure
// that an empty verbs list is not decoded as nil. On the other hand, an undefined verbs list
// will lead to nil because this decoding for Verbs is not invoked.
//
// TODO(sttts): this is due to a ugorji regression: https://github.com/ugorji/go/issues/119. Remove the
// workaround when the regression is fixed.
func (vs *Verbs) CodecDecodeSelf(decoder *codec.Decoder) {
m := []string{}
decoder.Decode(&m)
if len(m) == 0 {
*vs = []string{}
} else {
*vs = m
}
}
// APIResourceList is a list of APIResource, it is used to expose the name of the
// resources supported in a specific group and version, and if the resource
// is namespaced.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment