Skip to content

Commit 0207363

Browse files
authored
Merge pull request kubernetes#76771 from baasbank/fix-lint-errors-pkg/printer
Fix lint errors pkg/printer
2 parents 8f5a62a + d97b7f2 commit 0207363

File tree

9 files changed

+32
-29
lines changed

9 files changed

+32
-29
lines changed

hack/.golint_failures

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ pkg/kubemark
199199
pkg/master
200200
pkg/master/controller/crdregistration
201201
pkg/master/tunneler
202-
pkg/printers
203-
pkg/printers/internalversion
204-
pkg/printers/storage
205202
pkg/proxy
206203
pkg/proxy/apis/config
207204
pkg/proxy/apis/config/v1alpha1

pkg/printers/interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func (fn ResourcePrinterFunc) PrintObj(obj runtime.Object, w io.Writer) error {
3737
return fn(obj, w)
3838
}
3939

40+
// PrintOptions struct defines a struct for various print options
4041
type PrintOptions struct {
4142
// supported Format types can be found in pkg/printers/printers.go
4243
OutputFormatType string

pkg/printers/internalversion/import_known_versions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ limitations under the License.
1616

1717
package internalversion
1818

19-
// These imports are the API groups the client will support.
20-
// TODO: Remove these manual install once we don't need legacy scheme in get comman
2119
import (
20+
// These imports are the API groups the client will support.
21+
// TODO: Remove these manual install once we don't need legacy scheme in get comman
2222
_ "k8s.io/kubernetes/pkg/apis/apps/install"
2323
_ "k8s.io/kubernetes/pkg/apis/authentication/install"
2424
_ "k8s.io/kubernetes/pkg/apis/authorization/install"

pkg/printers/internalversion/printers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ func printPod(pod *api.Pod, options printers.PrintOptions) ([]metav1beta1.TableR
706706
for _, condition := range pod.Status.Conditions {
707707
if condition.Type == conditionType {
708708
if condition.Status == api.ConditionTrue {
709-
trueConditions += 1
709+
trueConditions++
710710
}
711711
break
712712
}
@@ -2072,6 +2072,7 @@ func printBool(value bool) string {
20722072
return "False"
20732073
}
20742074

2075+
// SortableResourceNames - An array of sortable resource names
20752076
type SortableResourceNames []api.ResourceName
20762077

20772078
func (list SortableResourceNames) Len() int {

pkg/printers/internalversion/printers_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,8 +2866,8 @@ func TestPrintPodShowLabels(t *testing.T) {
28662866
}
28672867

28682868
func TestPrintService(t *testing.T) {
2869-
single_ExternalIP := []string{"80.11.12.10"}
2870-
mul_ExternalIP := []string{"80.11.12.10", "80.11.12.11"}
2869+
singleExternalIP := []string{"80.11.12.10"}
2870+
mulExternalIP := []string{"80.11.12.10", "80.11.12.11"}
28712871
tests := []struct {
28722872
service api.Service
28732873
expect string
@@ -2937,7 +2937,7 @@ func TestPrintService(t *testing.T) {
29372937
},
29382938
},
29392939
ClusterIP: "10.9.8.7",
2940-
ExternalIPs: single_ExternalIP,
2940+
ExternalIPs: singleExternalIP,
29412941
},
29422942
},
29432943
"test4\tLoadBalancer\t10.9.8.7\t80.11.12.10\t8888/tcp\t<unknown>\n",
@@ -2955,7 +2955,7 @@ func TestPrintService(t *testing.T) {
29552955
},
29562956
},
29572957
ClusterIP: "10.9.8.7",
2958-
ExternalIPs: single_ExternalIP,
2958+
ExternalIPs: singleExternalIP,
29592959
},
29602960
Status: api.ServiceStatus{
29612961
LoadBalancer: api.LoadBalancerStatus{
@@ -2983,7 +2983,7 @@ func TestPrintService(t *testing.T) {
29832983
},
29842984
},
29852985
ClusterIP: "10.9.8.7",
2986-
ExternalIPs: mul_ExternalIP,
2986+
ExternalIPs: mulExternalIP,
29872987
},
29882988
Status: api.ServiceStatus{
29892989
LoadBalancer: api.LoadBalancerStatus{

pkg/printers/storage/storage.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ import (
2525
"k8s.io/kubernetes/pkg/printers"
2626
)
2727

28+
// TableConvertor struct - converts objects to metav1beta1.Table using printers.TableGenerator
2829
type TableConvertor struct {
2930
printers.TableGenerator
3031
}
3132

33+
// ConvertToTable method - converts objects to metav1beta1.Table objects using TableGenerator
3234
func (c TableConvertor) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1beta1.Table, error) {
3335
noHeaders := false
3436
if tableOptions != nil {

pkg/printers/tablegenerator.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ import (
2727
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2828
)
2929

30+
// TableGenerator - an interface for generating metav1beta1.Table provided a runtime.Object
3031
type TableGenerator interface {
3132
GenerateTable(obj runtime.Object, options PrintOptions) (*metav1beta1.Table, error)
3233
}
3334

35+
// PrintHandler - interface to handle printing provided an array of metav1beta1.TableColumnDefinition
3436
type PrintHandler interface {
3537
TableHandler(columns []metav1beta1.TableColumnDefinition, printFunc interface{}) error
3638
DefaultTableHandler(columns []metav1beta1.TableColumnDefinition, printFunc interface{}) error
@@ -64,11 +66,12 @@ func NewTableGenerator() *HumanReadablePrinter {
6466
}
6567
}
6668

67-
func (a *HumanReadablePrinter) With(fns ...func(PrintHandler)) *HumanReadablePrinter {
69+
// With method - accepts a list of builder functions that modify HumanReadablePrinter
70+
func (h *HumanReadablePrinter) With(fns ...func(PrintHandler)) *HumanReadablePrinter {
6871
for _, fn := range fns {
69-
fn(a)
72+
fn(h)
7073
}
71-
return a
74+
return h
7275
}
7376

7477
// GenerateTable returns a table for the provided object, using the printer registered for that type. It returns

pkg/printers/tableprinter.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
)
3232

3333
var _ ResourcePrinter = &HumanReadablePrinter{}
34-
3534
var withNamespacePrefixColumns = []string{"NAMESPACE"} // TODO(erictune): print cluster name too.
3635

3736
// NewTablePrinter creates a printer suitable for calling PrintObj().
@@ -45,6 +44,13 @@ func NewTablePrinter(options PrintOptions) *HumanReadablePrinter {
4544
return printer
4645
}
4746

47+
func printHeader(columnNames []string, w io.Writer) error {
48+
if _, err := fmt.Fprintf(w, "%s\n", strings.Join(columnNames, "\t")); err != nil {
49+
return err
50+
}
51+
return nil
52+
}
53+
4854
// PrintObj prints the obj in a human-friendly format according to the type of the obj.
4955
func (h *HumanReadablePrinter) PrintObj(obj runtime.Object, output io.Writer) error {
5056
w, found := output.(*tabwriter.Writer)
@@ -299,13 +305,6 @@ func printRowsForHandlerEntry(output io.Writer, handler *handlerEntry, obj runti
299305
return results[1].Interface().(error)
300306
}
301307

302-
func printHeader(columnNames []string, w io.Writer) error {
303-
if _, err := fmt.Fprintf(w, "%s\n", strings.Join(columnNames, "\t")); err != nil {
304-
return err
305-
}
306-
return nil
307-
}
308-
309308
// printRows writes the provided rows to output.
310309
func printRows(output io.Writer, rows []metav1beta1.TableRow, options PrintOptions) {
311310
for _, row := range rows {

test/integration/auth/auth_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func timeoutPath(resource, namespace, name string) string {
109109
}
110110

111111
// Bodies for requests used in subsequent tests.
112-
var aPod string = `
112+
var aPod = `
113113
{
114114
"kind": "Pod",
115115
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
@@ -127,7 +127,7 @@ var aPod string = `
127127
}
128128
}
129129
`
130-
var aRC string = `
130+
var aRC = `
131131
{
132132
"kind": "ReplicationController",
133133
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
@@ -160,7 +160,7 @@ var aRC string = `
160160
}
161161
}
162162
`
163-
var aService string = `
163+
var aService = `
164164
{
165165
"kind": "Service",
166166
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
@@ -184,7 +184,7 @@ var aService string = `
184184
}
185185
}
186186
`
187-
var aNode string = `
187+
var aNode = `
188188
{
189189
"kind": "Node",
190190
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
@@ -215,7 +215,7 @@ func aEvent(namespace string) string {
215215
`
216216
}
217217

218-
var aBinding string = `
218+
var aBinding = `
219219
{
220220
"kind": "Binding",
221221
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
@@ -238,7 +238,7 @@ var emptyEndpoints = `
238238
}
239239
`
240240

241-
var aEndpoints string = `
241+
var aEndpoints = `
242242
{
243243
"kind": "Endpoints",
244244
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
@@ -263,7 +263,7 @@ var aEndpoints string = `
263263
}
264264
`
265265

266-
var deleteNow string = `
266+
var deleteNow = `
267267
{
268268
"kind": "DeleteOptions",
269269
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",

0 commit comments

Comments
 (0)