mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Workaround ugorji/go/codecs regression
This commit is contained in:
parent
0301487de0
commit
a8ebc131de
@ -27,8 +27,9 @@ package v1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/ugorji/go/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TypeMeta describes an individual object in an API response or request
|
// 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))
|
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
|
// 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
|
// resources supported in a specific group and version, and if the resource
|
||||||
// is namespaced.
|
// is namespaced.
|
||||||
|
Loading…
Reference in New Issue
Block a user