Add DecodeIntoWithSpecifiedVersionKind() to Decoder interface.
The function validate/default the body with the passed in apiVersion and Kind. It's called in createHandler and UpdateResource
This commit is contained in:
@@ -38,6 +38,7 @@ type ObjectCodec interface {
|
||||
type Decoder interface {
|
||||
Decode(data []byte) (Object, error)
|
||||
DecodeInto(data []byte, obj Object) error
|
||||
DecodeIntoWithSpecifiedVersionKind(data []byte, obj Object, kind, version string) error
|
||||
}
|
||||
|
||||
// Encoder defines methods for serializing API objects into bytes
|
||||
|
@@ -458,6 +458,10 @@ func (s *Scheme) DecodeInto(data []byte, obj Object) error {
|
||||
return s.raw.DecodeInto(data, obj)
|
||||
}
|
||||
|
||||
func (s *Scheme) DecodeIntoWithSpecifiedVersionKind(data []byte, obj Object, version, kind string) error {
|
||||
return s.raw.DecodeIntoWithSpecifiedVersionKind(data, obj, version, kind)
|
||||
}
|
||||
|
||||
// Copy does a deep copy of an API object. Useful mostly for tests.
|
||||
func (s *Scheme) Copy(src Object) (Object, error) {
|
||||
dst, err := s.raw.DeepCopy(src)
|
||||
|
@@ -74,6 +74,10 @@ func (unstructuredJSONScheme) DecodeInto(data []byte, obj Object) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (unstructuredJSONScheme) DecodeIntoWithSpecifiedVersionKind(data []byte, obj Object, kind, version string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (unstructuredJSONScheme) DataVersionAndKind(data []byte) (version, kind string, err error) {
|
||||
obj := TypeMeta{}
|
||||
if err := json.Unmarshal(data, &obj); err != nil {
|
||||
|
Reference in New Issue
Block a user