diff --git a/hack/.golint_failures b/hack/.golint_failures index 7f62c2ee815..93cc24fffe5 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -199,9 +199,6 @@ pkg/kubemark pkg/master pkg/master/controller/crdregistration pkg/master/tunneler -pkg/printers -pkg/printers/internalversion -pkg/printers/storage pkg/proxy pkg/proxy/apis/config pkg/proxy/apis/config/v1alpha1 diff --git a/pkg/printers/interface.go b/pkg/printers/interface.go index 6d40b9c0e23..02a6f948e0b 100644 --- a/pkg/printers/interface.go +++ b/pkg/printers/interface.go @@ -37,6 +37,7 @@ func (fn ResourcePrinterFunc) PrintObj(obj runtime.Object, w io.Writer) error { return fn(obj, w) } +// PrintOptions struct defines a struct for various print options type PrintOptions struct { // supported Format types can be found in pkg/printers/printers.go OutputFormatType string diff --git a/pkg/printers/internalversion/import_known_versions.go b/pkg/printers/internalversion/import_known_versions.go index 154e6c76a6c..47a379762bd 100644 --- a/pkg/printers/internalversion/import_known_versions.go +++ b/pkg/printers/internalversion/import_known_versions.go @@ -16,9 +16,9 @@ limitations under the License. package internalversion -// These imports are the API groups the client will support. -// TODO: Remove these manual install once we don't need legacy scheme in get comman import ( + // These imports are the API groups the client will support. + // TODO: Remove these manual install once we don't need legacy scheme in get comman _ "k8s.io/kubernetes/pkg/apis/apps/install" _ "k8s.io/kubernetes/pkg/apis/authentication/install" _ "k8s.io/kubernetes/pkg/apis/authorization/install" diff --git a/pkg/printers/internalversion/printers.go b/pkg/printers/internalversion/printers.go index b02f04c38bc..fd1d2172fd9 100644 --- a/pkg/printers/internalversion/printers.go +++ b/pkg/printers/internalversion/printers.go @@ -706,7 +706,7 @@ func printPod(pod *api.Pod, options printers.PrintOptions) ([]metav1beta1.TableR for _, condition := range pod.Status.Conditions { if condition.Type == conditionType { if condition.Status == api.ConditionTrue { - trueConditions += 1 + trueConditions++ } break } @@ -2072,6 +2072,7 @@ func printBool(value bool) string { return "False" } +// SortableResourceNames - An array of sortable resource names type SortableResourceNames []api.ResourceName func (list SortableResourceNames) Len() int { diff --git a/pkg/printers/internalversion/printers_test.go b/pkg/printers/internalversion/printers_test.go index f3a7eaf288c..a0acbf90ca3 100644 --- a/pkg/printers/internalversion/printers_test.go +++ b/pkg/printers/internalversion/printers_test.go @@ -2866,8 +2866,8 @@ func TestPrintPodShowLabels(t *testing.T) { } func TestPrintService(t *testing.T) { - single_ExternalIP := []string{"80.11.12.10"} - mul_ExternalIP := []string{"80.11.12.10", "80.11.12.11"} + singleExternalIP := []string{"80.11.12.10"} + mulExternalIP := []string{"80.11.12.10", "80.11.12.11"} tests := []struct { service api.Service expect string @@ -2937,7 +2937,7 @@ func TestPrintService(t *testing.T) { }, }, ClusterIP: "10.9.8.7", - ExternalIPs: single_ExternalIP, + ExternalIPs: singleExternalIP, }, }, "test4\tLoadBalancer\t10.9.8.7\t80.11.12.10\t8888/tcp\t\n", @@ -2955,7 +2955,7 @@ func TestPrintService(t *testing.T) { }, }, ClusterIP: "10.9.8.7", - ExternalIPs: single_ExternalIP, + ExternalIPs: singleExternalIP, }, Status: api.ServiceStatus{ LoadBalancer: api.LoadBalancerStatus{ @@ -2983,7 +2983,7 @@ func TestPrintService(t *testing.T) { }, }, ClusterIP: "10.9.8.7", - ExternalIPs: mul_ExternalIP, + ExternalIPs: mulExternalIP, }, Status: api.ServiceStatus{ LoadBalancer: api.LoadBalancerStatus{ diff --git a/pkg/printers/storage/storage.go b/pkg/printers/storage/storage.go index 9dcc71e5d38..d388d959694 100644 --- a/pkg/printers/storage/storage.go +++ b/pkg/printers/storage/storage.go @@ -25,10 +25,12 @@ import ( "k8s.io/kubernetes/pkg/printers" ) +// TableConvertor struct - converts objects to metav1beta1.Table using printers.TableGenerator type TableConvertor struct { printers.TableGenerator } +// ConvertToTable method - converts objects to metav1beta1.Table objects using TableGenerator func (c TableConvertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) { noHeaders := false if tableOptions != nil { diff --git a/pkg/printers/tablegenerator.go b/pkg/printers/tablegenerator.go index bbfd7c54696..423cee12e9c 100644 --- a/pkg/printers/tablegenerator.go +++ b/pkg/printers/tablegenerator.go @@ -27,10 +27,12 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" ) +// TableGenerator - an interface for generating metav1beta1.Table provided a runtime.Object type TableGenerator interface { GenerateTable(obj runtime.Object, options PrintOptions) (*metav1beta1.Table, error) } +// PrintHandler - interface to handle printing provided an array of metav1beta1.TableColumnDefinition type PrintHandler interface { TableHandler(columns []metav1beta1.TableColumnDefinition, printFunc interface{}) error DefaultTableHandler(columns []metav1beta1.TableColumnDefinition, printFunc interface{}) error @@ -64,11 +66,12 @@ func NewTableGenerator() *HumanReadablePrinter { } } -func (a *HumanReadablePrinter) With(fns ...func(PrintHandler)) *HumanReadablePrinter { +// With method - accepts a list of builder functions that modify HumanReadablePrinter +func (h *HumanReadablePrinter) With(fns ...func(PrintHandler)) *HumanReadablePrinter { for _, fn := range fns { - fn(a) + fn(h) } - return a + return h } // GenerateTable returns a table for the provided object, using the printer registered for that type. It returns diff --git a/pkg/printers/tableprinter.go b/pkg/printers/tableprinter.go index 9a5e3bb5e08..81032e473b8 100644 --- a/pkg/printers/tableprinter.go +++ b/pkg/printers/tableprinter.go @@ -31,7 +31,6 @@ import ( ) var _ ResourcePrinter = &HumanReadablePrinter{} - var withNamespacePrefixColumns = []string{"NAMESPACE"} // TODO(erictune): print cluster name too. // NewTablePrinter creates a printer suitable for calling PrintObj(). @@ -45,6 +44,13 @@ func NewTablePrinter(options PrintOptions) *HumanReadablePrinter { return printer } +func printHeader(columnNames []string, w io.Writer) error { + if _, err := fmt.Fprintf(w, "%s\n", strings.Join(columnNames, "\t")); err != nil { + return err + } + return nil +} + // PrintObj prints the obj in a human-friendly format according to the type of the obj. func (h *HumanReadablePrinter) PrintObj(obj runtime.Object, output io.Writer) error { w, found := output.(*tabwriter.Writer) @@ -299,13 +305,6 @@ func printRowsForHandlerEntry(output io.Writer, handler *handlerEntry, obj runti return results[1].Interface().(error) } -func printHeader(columnNames []string, w io.Writer) error { - if _, err := fmt.Fprintf(w, "%s\n", strings.Join(columnNames, "\t")); err != nil { - return err - } - return nil -} - // printRows writes the provided rows to output. func printRows(output io.Writer, rows []metav1beta1.TableRow, options PrintOptions) { for _, row := range rows { diff --git a/test/integration/auth/auth_test.go b/test/integration/auth/auth_test.go index fdacb480408..70b889a5596 100644 --- a/test/integration/auth/auth_test.go +++ b/test/integration/auth/auth_test.go @@ -109,7 +109,7 @@ func timeoutPath(resource, namespace, name string) string { } // Bodies for requests used in subsequent tests. -var aPod string = ` +var aPod = ` { "kind": "Pod", "apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `", @@ -127,7 +127,7 @@ var aPod string = ` } } ` -var aRC string = ` +var aRC = ` { "kind": "ReplicationController", "apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `", @@ -160,7 +160,7 @@ var aRC string = ` } } ` -var aService string = ` +var aService = ` { "kind": "Service", "apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `", @@ -184,7 +184,7 @@ var aService string = ` } } ` -var aNode string = ` +var aNode = ` { "kind": "Node", "apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `", @@ -215,7 +215,7 @@ func aEvent(namespace string) string { ` } -var aBinding string = ` +var aBinding = ` { "kind": "Binding", "apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `", @@ -238,7 +238,7 @@ var emptyEndpoints = ` } ` -var aEndpoints string = ` +var aEndpoints = ` { "kind": "Endpoints", "apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `", @@ -263,7 +263,7 @@ var aEndpoints string = ` } ` -var deleteNow string = ` +var deleteNow = ` { "kind": "DeleteOptions", "apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",