mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 03:57:41 +00:00
apimachinery: normal conversion code path for Unstructured in ConvertToVersion
This commit is contained in:
parent
44ffcdd9c5
commit
916622105d
@ -167,10 +167,14 @@ func (c *codec) Decode(data []byte, defaultGVK *schema.GroupVersionKind, into ru
|
|||||||
// conversion if necessary. Unversioned objects (according to the ObjectTyper) are output as is.
|
// conversion if necessary. Unversioned objects (according to the ObjectTyper) are output as is.
|
||||||
func (c *codec) Encode(obj runtime.Object, w io.Writer) error {
|
func (c *codec) Encode(obj runtime.Object, w io.Writer) error {
|
||||||
switch obj.(type) {
|
switch obj.(type) {
|
||||||
case *runtime.Unknown, runtime.Unstructured:
|
case *runtime.Unknown:
|
||||||
return c.encoder.Encode(obj, w)
|
return c.encoder.Encode(obj, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: for runtime.Unstructured, the typer will return the GVK in the object and we will do conversion as normal below.
|
||||||
|
// For the normal runtime.Scheme converter the conversion will be a no-op for Unstructured. For CustomResources
|
||||||
|
// the conversion will actually do something.
|
||||||
|
|
||||||
gvks, isUnversioned, err := c.typer.ObjectKinds(obj)
|
gvks, isUnversioned, err := c.typer.ObjectKinds(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user