Fix bunch of issues with conversion generator.
This commit is contained in:
@@ -88,46 +88,49 @@ func (re Unknown) MarshalJSON() ([]byte, error) {
|
||||
return re.Raw, nil
|
||||
}
|
||||
|
||||
func Convert_runtime_Object_To_runtime_RawExtension(in *Object, out *RawExtension, s conversion.Scope) error {
|
||||
if in == nil {
|
||||
out.Raw = []byte("null")
|
||||
return nil
|
||||
}
|
||||
obj := *in
|
||||
if unk, ok := obj.(*Unknown); ok {
|
||||
if unk.Raw != nil {
|
||||
out.Raw = unk.Raw
|
||||
return nil
|
||||
}
|
||||
obj = out.Object
|
||||
}
|
||||
if obj == nil {
|
||||
out.Raw = nil
|
||||
return nil
|
||||
}
|
||||
out.Object = obj
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_runtime_RawExtension_To_runtime_Object(in *RawExtension, out *Object, s conversion.Scope) error {
|
||||
if in.Object != nil {
|
||||
*out = in.Object
|
||||
return nil
|
||||
}
|
||||
data := in.Raw
|
||||
if len(data) == 0 || (len(data) == 4 && string(data) == "null") {
|
||||
*out = nil
|
||||
return nil
|
||||
}
|
||||
*out = &Unknown{
|
||||
Raw: data,
|
||||
// TODO: Set ContentEncoding and ContentType appropriately.
|
||||
// Currently we set ContentTypeJSON to make tests passing.
|
||||
ContentType: ContentTypeJSON,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DefaultEmbeddedConversions() []interface{} {
|
||||
return []interface{}{
|
||||
func(in *Object, out *RawExtension, s conversion.Scope) error {
|
||||
if in == nil {
|
||||
out.Raw = []byte("null")
|
||||
return nil
|
||||
}
|
||||
obj := *in
|
||||
if unk, ok := obj.(*Unknown); ok {
|
||||
if unk.Raw != nil {
|
||||
out.Raw = unk.Raw
|
||||
return nil
|
||||
}
|
||||
obj = out.Object
|
||||
}
|
||||
if obj == nil {
|
||||
out.Raw = nil
|
||||
return nil
|
||||
}
|
||||
out.Object = obj
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *RawExtension, out *Object, s conversion.Scope) error {
|
||||
if in.Object != nil {
|
||||
*out = in.Object
|
||||
return nil
|
||||
}
|
||||
data := in.Raw
|
||||
if len(data) == 0 || (len(data) == 4 && string(data) == "null") {
|
||||
*out = nil
|
||||
return nil
|
||||
}
|
||||
*out = &Unknown{
|
||||
Raw: data,
|
||||
// TODO: Set ContentEncoding and ContentType appropriately.
|
||||
// Currently we set ContentTypeJSON to make tests passing.
|
||||
ContentType: ContentTypeJSON,
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Convert_runtime_Object_To_runtime_RawExtension,
|
||||
Convert_runtime_RawExtension_To_runtime_Object,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user