diff --git a/pkg/printers/humanreadable.go b/pkg/printers/humanreadable.go index 5b86be92fea..8ef5f38cedc 100644 --- a/pkg/printers/humanreadable.go +++ b/pkg/printers/humanreadable.go @@ -114,17 +114,25 @@ func (h *HumanReadablePrinter) EnsurePrintHeaders() { // See ValidatePrintHandlerFunc for required method signature. func (h *HumanReadablePrinter) Handler(columns, columnsWithWide []string, printFunc interface{}) error { var columnDefinitions []metav1beta1.TableColumnDefinition - for _, column := range columns { + for i, column := range columns { + format := "" + if i == 0 && strings.EqualFold(column, "name") { + format = "name" + } + columnDefinitions = append(columnDefinitions, metav1beta1.TableColumnDefinition{ - Name: column, - Type: "string", + Name: column, + Description: column, + Type: "string", + Format: format, }) } for _, column := range columnsWithWide { columnDefinitions = append(columnDefinitions, metav1beta1.TableColumnDefinition{ - Name: column, - Type: "string", - Priority: 1, + Name: column, + Description: column, + Type: "string", + Priority: 1, }) } @@ -631,6 +639,13 @@ func (h *HumanReadablePrinter) legacyPrinterToTable(obj runtime.Object, handler args := []reflect.Value{reflect.ValueOf(obj), reflect.ValueOf(buf), reflect.ValueOf(options)} if meta.IsListType(obj) { + listInterface, ok := obj.(metav1.ListInterface) + if ok { + table.ListMeta.SelfLink = listInterface.GetSelfLink() + table.ListMeta.ResourceVersion = listInterface.GetResourceVersion() + table.ListMeta.Continue = listInterface.GetContinue() + } + // TODO: this uses more memory than it has to, as we refactor printers we should remove the need // for this. args[0] = reflect.ValueOf(obj) diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go index 647b9401b1e..8b7a056113e 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/resttest/resttest.go @@ -1312,7 +1312,7 @@ func (t *Tester) testListTableConversion(obj runtime.Object, assignFn AssignFunc if len(columns) == 0 { t.Errorf("unexpected number of columns: %v", len(columns)) } - if columns[0].Name != "Name" || columns[0].Type != "string" || columns[0].Format != "name" { + if !strings.EqualFold(columns[0].Name, "Name") || columns[0].Type != "string" || columns[0].Format != "name" { t.Errorf("expect column 0 to be the name column: %#v", columns[0]) } for j, column := range columns {