Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
02073634
Unverified
Commit
02073634
authored
May 01, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #76771 from baasbank/fix-lint-errors-pkg/printer
Fix lint errors pkg/printer
parents
8f5a62af
d97b7f20
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
32 additions
and
29 deletions
+32
-29
.golint_failures
hack/.golint_failures
+0
-3
interface.go
pkg/printers/interface.go
+1
-0
import_known_versions.go
pkg/printers/internalversion/import_known_versions.go
+2
-2
printers.go
pkg/printers/internalversion/printers.go
+2
-1
printers_test.go
pkg/printers/internalversion/printers_test.go
+5
-5
storage.go
pkg/printers/storage/storage.go
+2
-0
tablegenerator.go
pkg/printers/tablegenerator.go
+6
-3
tableprinter.go
pkg/printers/tableprinter.go
+7
-8
auth_test.go
test/integration/auth/auth_test.go
+7
-7
No files found.
hack/.golint_failures
View file @
02073634
...
...
@@ -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
...
...
pkg/printers/interface.go
View file @
02073634
...
...
@@ -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
...
...
pkg/printers/internalversion/import_known_versions.go
View file @
02073634
...
...
@@ -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"
...
...
pkg/printers/internalversion/printers.go
View file @
02073634
...
...
@@ -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
{
...
...
pkg/printers/internalversion/printers_test.go
View file @
02073634
...
...
@@ -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
\t
LoadBalancer
\t
10.9.8.7
\t
80.11.12.10
\t
8888/tcp
\t
<unknown>
\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
{
...
...
pkg/printers/storage/storage.go
View file @
02073634
...
...
@@ -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
{
...
...
pkg/printers/tablegenerator.go
View file @
02073634
...
...
@@ -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
...
...
pkg/printers/tableprinter.go
View file @
02073634
...
...
@@ -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
{
...
...
test/integration/auth/auth_test.go
View file @
02073634
...
...
@@ -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
()
+
`",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment