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
b359b6bf
Unverified
Commit
b359b6bf
authored
Apr 16, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Apr 16, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #76683 from seans3/remove-skip-tabwriter
Removes test-only skipTabWriter from HumanReadablePrinter
parents
fe8cd08a
b99f49b5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
17 deletions
+9
-17
humanreadable.go
pkg/printers/humanreadable.go
+1
-9
printers_test.go
pkg/printers/internalversion/printers_test.go
+8
-8
No files found.
pkg/printers/humanreadable.go
View file @
b359b6bf
...
@@ -61,7 +61,6 @@ type HumanReadablePrinter struct {
...
@@ -61,7 +61,6 @@ type HumanReadablePrinter struct {
options
PrintOptions
options
PrintOptions
lastType
interface
{}
lastType
interface
{}
lastColumns
[]
metav1beta1
.
TableColumnDefinition
lastColumns
[]
metav1beta1
.
TableColumnDefinition
skipTabWriter
bool
}
}
var
_
PrintHandler
=
&
HumanReadablePrinter
{}
var
_
PrintHandler
=
&
HumanReadablePrinter
{}
...
@@ -82,13 +81,6 @@ func NewTablePrinter() *HumanReadablePrinter {
...
@@ -82,13 +81,6 @@ func NewTablePrinter() *HumanReadablePrinter {
}
}
}
}
// AddTabWriter sets whether the PrintObj function will format with tabwriter (true
// by default).
func
(
a
*
HumanReadablePrinter
)
AddTabWriter
(
t
bool
)
*
HumanReadablePrinter
{
a
.
skipTabWriter
=
!
t
return
a
}
func
(
a
*
HumanReadablePrinter
)
With
(
fns
...
func
(
PrintHandler
))
*
HumanReadablePrinter
{
func
(
a
*
HumanReadablePrinter
)
With
(
fns
...
func
(
PrintHandler
))
*
HumanReadablePrinter
{
for
_
,
fn
:=
range
fns
{
for
_
,
fn
:=
range
fns
{
fn
(
a
)
fn
(
a
)
...
@@ -226,7 +218,7 @@ func printHeader(columnNames []string, w io.Writer) error {
...
@@ -226,7 +218,7 @@ func printHeader(columnNames []string, w io.Writer) error {
// PrintObj prints the obj in a human-friendly format according to the type of the obj.
// 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
{
func
(
h
*
HumanReadablePrinter
)
PrintObj
(
obj
runtime
.
Object
,
output
io
.
Writer
)
error
{
w
,
found
:=
output
.
(
*
tabwriter
.
Writer
)
w
,
found
:=
output
.
(
*
tabwriter
.
Writer
)
if
!
found
&&
!
h
.
skipTabWriter
{
if
!
found
{
w
=
GetNewTabWriter
(
output
)
w
=
GetNewTabWriter
(
output
)
output
=
w
output
=
w
defer
w
.
Flush
()
defer
w
.
Flush
()
...
...
pkg/printers/internalversion/printers_test.go
View file @
b359b6bf
...
@@ -1477,32 +1477,32 @@ func TestPrintPodTable(t *testing.T) {
...
@@ -1477,32 +1477,32 @@ func TestPrintPodTable(t *testing.T) {
}{
}{
{
{
obj
:
runningPod
,
opts
:
printers
.
PrintOptions
{},
obj
:
runningPod
,
opts
:
printers
.
PrintOptions
{},
expect
:
"NAME
\t
READY
\t
STATUS
\t
RESTARTS
\t
AGE
\n
test1
\t
1/2
\t
Running
\t
6
\t
<unknown>
\n
"
,
expect
:
"NAME
READY STATUS RESTARTS AGE
\n
test1 1/2 Running 6
<unknown>
\n
"
,
},
},
{
{
obj
:
runningPod
,
opts
:
printers
.
PrintOptions
{
WithKind
:
true
,
Kind
:
schema
.
GroupKind
{
Kind
:
"Pod"
}},
obj
:
runningPod
,
opts
:
printers
.
PrintOptions
{
WithKind
:
true
,
Kind
:
schema
.
GroupKind
{
Kind
:
"Pod"
}},
expect
:
"NAME
\t
READY
\t
STATUS
\t
RESTARTS
\t
AGE
\n
pod/test1
\t
1/2
\t
Running
\t
6
\t
<unknown>
\n
"
,
expect
:
"NAME
READY STATUS RESTARTS AGE
\n
pod/test1 1/2 Running 6
<unknown>
\n
"
,
},
},
{
{
obj
:
runningPod
,
opts
:
printers
.
PrintOptions
{
ShowLabels
:
true
},
obj
:
runningPod
,
opts
:
printers
.
PrintOptions
{
ShowLabels
:
true
},
expect
:
"NAME
\t
READY
\t
STATUS
\t
RESTARTS
\t
AGE
\t
LABELS
\n
test1
\t
1/2
\t
Running
\t
6
\t
<unknown>
\t
a=1,b=2
\n
"
,
expect
:
"NAME
READY STATUS RESTARTS AGE LABELS
\n
test1 1/2 Running 6 <unknown>
a=1,b=2
\n
"
,
},
},
{
{
obj
:
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
runningPod
,
*
failedPod
}},
opts
:
printers
.
PrintOptions
{
ColumnLabels
:
[]
string
{
"a"
}},
obj
:
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
runningPod
,
*
failedPod
}},
opts
:
printers
.
PrintOptions
{
ColumnLabels
:
[]
string
{
"a"
}},
expect
:
"NAME
\t
READY
\t
STATUS
\t
RESTARTS
\t
AGE
\t
A
\n
test1
\t
1/2
\t
Running
\t
6
\t
<unknown>
\t
1
\n
test2
\t
1/2
\t
Failed
\t
6
\t
<unknown>
\t
\n
"
,
expect
:
"NAME
READY STATUS RESTARTS AGE A
\n
test1 1/2 Running 6 <unknown> 1
\n
test2 1/2 Failed 6 <unknown>
\n
"
,
},
},
{
{
obj
:
runningPod
,
opts
:
printers
.
PrintOptions
{
NoHeaders
:
true
},
obj
:
runningPod
,
opts
:
printers
.
PrintOptions
{
NoHeaders
:
true
},
expect
:
"test1
\t
1/2
\t
Running
\t
6
\t
<unknown>
\n
"
,
expect
:
"test1
1/2 Running 6
<unknown>
\n
"
,
},
},
{
{
obj
:
failedPod
,
opts
:
printers
.
PrintOptions
{},
obj
:
failedPod
,
opts
:
printers
.
PrintOptions
{},
expect
:
"NAME
\t
READY
\t
STATUS
\t
RESTARTS
\t
AGE
\n
test2
\t
1/2
\t
Failed
\t
6
\t
<unknown>
\n
"
,
expect
:
"NAME
READY STATUS RESTARTS AGE
\n
test2 1/2 Failed 6
<unknown>
\n
"
,
ignoreLegacy
:
true
,
// filtering is not done by the printer in the legacy path
ignoreLegacy
:
true
,
// filtering is not done by the printer in the legacy path
},
},
{
{
obj
:
failedPod
,
opts
:
printers
.
PrintOptions
{},
obj
:
failedPod
,
opts
:
printers
.
PrintOptions
{},
expect
:
"NAME
\t
READY
\t
STATUS
\t
RESTARTS
\t
AGE
\n
test2
\t
1/2
\t
Failed
\t
6
\t
<unknown>
\n
"
,
expect
:
"NAME
READY STATUS RESTARTS AGE
\n
test2 1/2 Failed 6
<unknown>
\n
"
,
},
},
}
}
...
@@ -1513,7 +1513,7 @@ func TestPrintPodTable(t *testing.T) {
...
@@ -1513,7 +1513,7 @@ func TestPrintPodTable(t *testing.T) {
}
}
verifyTable
(
t
,
table
)
verifyTable
(
t
,
table
)
buf
:=
&
bytes
.
Buffer
{}
buf
:=
&
bytes
.
Buffer
{}
p
:=
printers
.
NewHumanReadablePrinter
(
test
.
opts
)
.
With
(
AddHandlers
)
.
AddTabWriter
(
false
)
p
:=
printers
.
NewHumanReadablePrinter
(
test
.
opts
)
.
With
(
AddHandlers
)
if
err
:=
p
.
PrintObj
(
table
,
buf
);
err
!=
nil
{
if
err
:=
p
.
PrintObj
(
table
,
buf
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
...
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