Merge pull request #26044 from smarterclayton/multiversion_encode
Automatic merge from submit-queue Guarantee that Encode handles nested objects again
This commit is contained in:
@@ -197,7 +197,7 @@ func RunPatch(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
originalObjJS, err := runtime.Encode(api.Codecs.LegacyCodec(), info.VersionedObject.(runtime.Object))
|
||||
originalObjJS, err := runtime.Encode(api.Codecs.LegacyCodec(mapping.GroupVersionKind.GroupVersion()), info.VersionedObject.(runtime.Object))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -195,20 +195,11 @@ func (p *VersionedPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
if len(p.versions) == 0 {
|
||||
return fmt.Errorf("no version specified, object cannot be converted")
|
||||
}
|
||||
for _, version := range p.versions {
|
||||
if version.IsEmpty() {
|
||||
continue
|
||||
}
|
||||
converted, err := p.converter.ConvertToVersion(obj, version)
|
||||
if runtime.IsNotRegisteredError(err) {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return p.printer.PrintObj(converted, w)
|
||||
converted, err := p.converter.ConvertToVersion(obj, unversioned.GroupVersions(p.versions))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("the object cannot be converted to any of the versions: %v", p.versions)
|
||||
return p.printer.PrintObj(converted, w)
|
||||
}
|
||||
|
||||
// TODO: implement HandledResources()
|
||||
|
Reference in New Issue
Block a user