Drop unnecessary json.Marshal

yaml.Marshal under the covers invokes json.Marshal and then JSONToYAML
conversion which was done here manually.
This commit is contained in:
Maciej Szulik 2022-06-02 16:14:22 +02:00
parent 451e1fa8bc
commit e4fca64690
No known key found for this signature in database
GPG Key ID: F15E55D276FA84C4

View File

@ -17,7 +17,6 @@ limitations under the License.
package printers
import (
"encoding/json"
"fmt"
"io"
"reflect"
@ -58,11 +57,7 @@ func (p *YAMLPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
if InternalObjectPreventer.IsForbidden(reflect.Indirect(reflect.ValueOf(obj.Object.Object)).Type().PkgPath()) {
return fmt.Errorf(InternalObjectPrinterErr)
}
data, err := json.Marshal(obj)
if err != nil {
return err
}
data, err = yaml.JSONToYAML(data)
data, err := yaml.Marshal(obj)
if err != nil {
return err
}