mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
remove decoder from name printing
This commit is contained in:
parent
f5a91f4173
commit
dfa5bfd39f
@ -40,7 +40,6 @@ go_library(
|
|||||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/util/jsonpath:go_default_library",
|
"//vendor/k8s.io/client-go/util/jsonpath:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -390,10 +390,25 @@ func TestNamePrinter(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Items: []runtime.RawExtension{
|
Items: []runtime.RawExtension{
|
||||||
{
|
{
|
||||||
Raw: []byte(`{"kind": "Pod", "apiVersion": "v1", "metadata": { "name": "foo"}}`),
|
Object: &v1.Pod{
|
||||||
|
TypeMeta: metav1.TypeMeta{
|
||||||
|
Kind: "Pod",
|
||||||
|
},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "foo",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Raw: []byte(`{"kind": "Pod", "apiVersion": "v1", "metadata": { "name": "bar"}}`),
|
Object: &unstructured.Unstructured{
|
||||||
|
Object: map[string]interface{}{
|
||||||
|
"kind": "Pod",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": map[string]interface{}{
|
||||||
|
"name": "bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -575,7 +590,6 @@ func TestPrinters(t *testing.T) {
|
|||||||
"jsonpath": jsonpathPrinter,
|
"jsonpath": jsonpathPrinter,
|
||||||
"name": &printers.NamePrinter{
|
"name": &printers.NamePrinter{
|
||||||
Typer: legacyscheme.Scheme,
|
Typer: legacyscheme.Scheme,
|
||||||
Decoders: []runtime.Decoder{legacyscheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
objects := map[string]runtime.Object{
|
objects := map[string]runtime.Object{
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NamePrinter is an implementation of ResourcePrinter which outputs "resource/name" pair of an object.
|
// NamePrinter is an implementation of ResourcePrinter which outputs "resource/name" pair of an object.
|
||||||
@ -39,7 +38,6 @@ type NamePrinter struct {
|
|||||||
// finalized "successful" message.
|
// finalized "successful" message.
|
||||||
Operation string
|
Operation string
|
||||||
|
|
||||||
Decoders []runtime.Decoder
|
|
||||||
Typer runtime.ObjectTyper
|
Typer runtime.ObjectTyper
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,9 +56,6 @@ func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if errs := runtime.DecodeList(items, p.Decoders...); len(errs) > 0 {
|
|
||||||
return utilerrors.NewAggregate(errs)
|
|
||||||
}
|
|
||||||
for _, obj := range items {
|
for _, obj := range items {
|
||||||
if err := p.PrintObj(obj, w); err != nil {
|
if err := p.PrintObj(obj, w); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/kubectl/scheme"
|
"k8s.io/kubernetes/pkg/kubectl/scheme"
|
||||||
@ -50,11 +49,9 @@ func (f *NamePrintFlags) Complete(successTemplate string) error {
|
|||||||
// Returns false if the specified outputFormat does not match a supported format.
|
// Returns false if the specified outputFormat does not match a supported format.
|
||||||
// Supported format types can be found in pkg/printers/printers.go
|
// Supported format types can be found in pkg/printers/printers.go
|
||||||
func (f *NamePrintFlags) ToPrinter(outputFormat string) (ResourcePrinter, error) {
|
func (f *NamePrintFlags) ToPrinter(outputFormat string) (ResourcePrinter, error) {
|
||||||
decoders := []runtime.Decoder{scheme.Codecs.UniversalDecoder(), unstructured.UnstructuredJSONScheme}
|
|
||||||
namePrinter := &NamePrinter{
|
namePrinter := &NamePrinter{
|
||||||
Operation: f.Operation,
|
Operation: f.Operation,
|
||||||
Typer: scheme.Scheme,
|
Typer: scheme.Scheme,
|
||||||
Decoders: decoders,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outputFormat = strings.ToLower(outputFormat)
|
outputFormat = strings.ToLower(outputFormat)
|
||||||
|
Loading…
Reference in New Issue
Block a user