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
dc5f6151
Unverified
Commit
dc5f6151
authored
Jul 19, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send correct headers for pod printing
parent
8770d124
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
8 deletions
+12
-8
humanreadable_flags_test.go
pkg/kubectl/cmd/get/humanreadable_flags_test.go
+2
-2
printers.go
pkg/printers/internalversion/printers.go
+5
-3
printers_test.go
pkg/printers/internalversion/printers_test.go
+1
-1
storage_test.go
pkg/registry/core/pod/storage/storage_test.go
+4
-2
No files found.
pkg/kubectl/cmd/get/humanreadable_flags_test.go
View file @
dc5f6151
...
@@ -61,7 +61,7 @@ func TestHumanReadablePrinterSupportsExpectedOptions(t *testing.T) {
...
@@ -61,7 +61,7 @@ func TestHumanReadablePrinterSupportsExpectedOptions(t *testing.T) {
{
{
name
:
"
\"
wide
\"
output format prints"
,
name
:
"
\"
wide
\"
output format prints"
,
outputFormat
:
"wide"
,
outputFormat
:
"wide"
,
expectedOutput
:
"NAME
\\
+READY
\\
+STATUS
\\
+RESTARTS
\\
+AGE
\\
+IP
\\
+NODE
\
n
foo
\\
+0/0
\\
+0
\\
+<unknown
>
\\
+<none>
\\
+<none>
\n
"
,
expectedOutput
:
"NAME
\\
+READY
\\
+STATUS
\\
+RESTARTS
\\
+AGE
\\
+IP
\\
+NODE
\
\
+NOMINATED NODE
\n
foo
\\
+0/0
\\
+0
\\
+<unknown>
\\
+<none
>
\\
+<none>
\\
+<none>
\n
"
,
},
},
{
{
name
:
"no-headers prints output with no headers"
,
name
:
"no-headers prints output with no headers"
,
...
@@ -72,7 +72,7 @@ func TestHumanReadablePrinterSupportsExpectedOptions(t *testing.T) {
...
@@ -72,7 +72,7 @@ func TestHumanReadablePrinterSupportsExpectedOptions(t *testing.T) {
name
:
"no-headers and a
\"
wide
\"
output format prints output with no headers and additional columns"
,
name
:
"no-headers and a
\"
wide
\"
output format prints output with no headers and additional columns"
,
outputFormat
:
"wide"
,
outputFormat
:
"wide"
,
noHeaders
:
true
,
noHeaders
:
true
,
expectedOutput
:
"foo
\\
+0/0
\\
+0
\\
+<unknown>
\\
+<none>
\\
+<none>
\n
"
,
expectedOutput
:
"foo
\\
+0/0
\\
+0
\\
+<unknown>
\\
+<none>
\\
+<none>
\
\
+<none>
\
n
"
,
},
},
{
{
name
:
"show-kind displays the resource's kind, even when printing a single type of resource"
,
name
:
"show-kind displays the resource's kind, even when printing a single type of resource"
,
...
...
pkg/printers/internalversion/printers.go
View file @
dc5f6151
...
@@ -84,6 +84,7 @@ func AddHandlers(h printers.PrintHandler) {
...
@@ -84,6 +84,7 @@ func AddHandlers(h printers.PrintHandler) {
{
Name
:
"Age"
,
Type
:
"string"
,
Description
:
metav1
.
ObjectMeta
{}
.
SwaggerDoc
()[
"creationTimestamp"
]},
{
Name
:
"Age"
,
Type
:
"string"
,
Description
:
metav1
.
ObjectMeta
{}
.
SwaggerDoc
()[
"creationTimestamp"
]},
{
Name
:
"IP"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
apiv1
.
PodStatus
{}
.
SwaggerDoc
()[
"podIP"
]},
{
Name
:
"IP"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
apiv1
.
PodStatus
{}
.
SwaggerDoc
()[
"podIP"
]},
{
Name
:
"Node"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
apiv1
.
PodSpec
{}
.
SwaggerDoc
()[
"nodeName"
]},
{
Name
:
"Node"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
apiv1
.
PodSpec
{}
.
SwaggerDoc
()[
"nodeName"
]},
{
Name
:
"Nominated Node"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
apiv1
.
PodStatus
{}
.
SwaggerDoc
()[
"nominatedNodeName"
]},
}
}
h
.
TableHandler
(
podColumnDefinitions
,
printPodList
)
h
.
TableHandler
(
podColumnDefinitions
,
printPodList
)
h
.
TableHandler
(
podColumnDefinitions
,
printPod
)
h
.
TableHandler
(
podColumnDefinitions
,
printPod
)
...
@@ -632,6 +633,7 @@ func printPod(pod *api.Pod, options printers.PrintOptions) ([]metav1beta1.TableR
...
@@ -632,6 +633,7 @@ func printPod(pod *api.Pod, options printers.PrintOptions) ([]metav1beta1.TableR
if
options
.
Wide
{
if
options
.
Wide
{
nodeName
:=
pod
.
Spec
.
NodeName
nodeName
:=
pod
.
Spec
.
NodeName
nominatedNodeName
:=
pod
.
Status
.
NominatedNodeName
podIP
:=
pod
.
Status
.
PodIP
podIP
:=
pod
.
Status
.
PodIP
if
podIP
==
""
{
if
podIP
==
""
{
podIP
=
"<none>"
podIP
=
"<none>"
...
@@ -639,10 +641,10 @@ func printPod(pod *api.Pod, options printers.PrintOptions) ([]metav1beta1.TableR
...
@@ -639,10 +641,10 @@ func printPod(pod *api.Pod, options printers.PrintOptions) ([]metav1beta1.TableR
if
nodeName
==
""
{
if
nodeName
==
""
{
nodeName
=
"<none>"
nodeName
=
"<none>"
}
}
row
.
Cells
=
append
(
row
.
Cells
,
podIP
,
nodeName
)
if
nominatedNodeName
==
""
{
if
len
(
pod
.
Status
.
NominatedNodeName
)
>
0
{
nominatedNodeName
=
"<none>"
row
.
Cells
=
append
(
row
.
Cells
,
pod
.
Status
.
NominatedNodeName
)
}
}
row
.
Cells
=
append
(
row
.
Cells
,
podIP
,
nodeName
,
nominatedNodeName
)
}
}
return
[]
metav1beta1
.
TableRow
{
row
},
nil
return
[]
metav1beta1
.
TableRow
{
row
},
nil
...
...
pkg/printers/internalversion/printers_test.go
View file @
dc5f6151
...
@@ -1686,7 +1686,7 @@ func TestPrintPodwide(t *testing.T) {
...
@@ -1686,7 +1686,7 @@ func TestPrintPodwide(t *testing.T) {
},
},
},
},
},
},
[]
metav1beta1
.
TableRow
{{
Cells
:
[]
interface
{}{
"test2"
,
"1/2"
,
"ContainerWaitingReason"
,
int64
(
6
),
"<unknown>"
,
"<none>"
,
"<none>"
}}},
[]
metav1beta1
.
TableRow
{{
Cells
:
[]
interface
{}{
"test2"
,
"1/2"
,
"ContainerWaitingReason"
,
int64
(
6
),
"<unknown>"
,
"<none>"
,
"<none>"
,
"<none>"
}}},
},
},
}
}
...
...
pkg/registry/core/pod/storage/storage_test.go
View file @
dc5f6151
...
@@ -417,6 +417,7 @@ func TestConvertToTableList(t *testing.T) {
...
@@ -417,6 +417,7 @@ func TestConvertToTableList(t *testing.T) {
{
Name
:
"Age"
,
Type
:
"string"
,
Description
:
metav1
.
ObjectMeta
{}
.
SwaggerDoc
()[
"creationTimestamp"
]},
{
Name
:
"Age"
,
Type
:
"string"
,
Description
:
metav1
.
ObjectMeta
{}
.
SwaggerDoc
()[
"creationTimestamp"
]},
{
Name
:
"IP"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
v1
.
PodStatus
{}
.
SwaggerDoc
()[
"podIP"
]},
{
Name
:
"IP"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
v1
.
PodStatus
{}
.
SwaggerDoc
()[
"podIP"
]},
{
Name
:
"Node"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
v1
.
PodSpec
{}
.
SwaggerDoc
()[
"nodeName"
]},
{
Name
:
"Node"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
v1
.
PodSpec
{}
.
SwaggerDoc
()[
"nodeName"
]},
{
Name
:
"Nominated Node"
,
Type
:
"string"
,
Priority
:
1
,
Description
:
v1
.
PodStatus
{}
.
SwaggerDoc
()[
"nominatedNodeName"
]},
}
}
pod1
:=
&
api
.
Pod
{
pod1
:=
&
api
.
Pod
{
...
@@ -435,6 +436,7 @@ func TestConvertToTableList(t *testing.T) {
...
@@ -435,6 +436,7 @@ func TestConvertToTableList(t *testing.T) {
{
Name
:
"ctr1"
,
State
:
api
.
ContainerState
{
Running
:
&
api
.
ContainerStateRunning
{}},
RestartCount
:
10
,
Ready
:
true
},
{
Name
:
"ctr1"
,
State
:
api
.
ContainerState
{
Running
:
&
api
.
ContainerStateRunning
{}},
RestartCount
:
10
,
Ready
:
true
},
{
Name
:
"ctr2"
,
State
:
api
.
ContainerState
{
Waiting
:
&
api
.
ContainerStateWaiting
{}},
RestartCount
:
0
},
{
Name
:
"ctr2"
,
State
:
api
.
ContainerState
{
Waiting
:
&
api
.
ContainerStateWaiting
{}},
RestartCount
:
0
},
},
},
NominatedNodeName
:
"nominated-node"
,
},
},
}
}
...
@@ -452,7 +454,7 @@ func TestConvertToTableList(t *testing.T) {
...
@@ -452,7 +454,7 @@ func TestConvertToTableList(t *testing.T) {
out
:
&
metav1beta1
.
Table
{
out
:
&
metav1beta1
.
Table
{
ColumnDefinitions
:
columns
,
ColumnDefinitions
:
columns
,
Rows
:
[]
metav1beta1
.
TableRow
{
Rows
:
[]
metav1beta1
.
TableRow
{
{
Cells
:
[]
interface
{}{
""
,
"0/0"
,
""
,
int64
(
0
),
"<unknown>"
,
"<none>"
,
"<none>"
},
Object
:
runtime
.
RawExtension
{
Object
:
&
api
.
Pod
{}}},
{
Cells
:
[]
interface
{}{
""
,
"0/0"
,
""
,
int64
(
0
),
"<unknown>"
,
"<none>"
,
"<none>"
,
"<none>"
},
Object
:
runtime
.
RawExtension
{
Object
:
&
api
.
Pod
{}}},
},
},
},
},
},
},
...
@@ -461,7 +463,7 @@ func TestConvertToTableList(t *testing.T) {
...
@@ -461,7 +463,7 @@ func TestConvertToTableList(t *testing.T) {
out
:
&
metav1beta1
.
Table
{
out
:
&
metav1beta1
.
Table
{
ColumnDefinitions
:
columns
,
ColumnDefinitions
:
columns
,
Rows
:
[]
metav1beta1
.
TableRow
{
Rows
:
[]
metav1beta1
.
TableRow
{
{
Cells
:
[]
interface
{}{
"foo"
,
"1/2"
,
"Pending"
,
int64
(
10
),
"1y"
,
"10.1.2.3"
,
"test-node"
},
Object
:
runtime
.
RawExtension
{
Object
:
pod1
}},
{
Cells
:
[]
interface
{}{
"foo"
,
"1/2"
,
"Pending"
,
int64
(
10
),
"1y"
,
"10.1.2.3"
,
"test-node"
,
"nominated-node"
},
Object
:
runtime
.
RawExtension
{
Object
:
pod1
}},
},
},
},
},
},
},
...
...
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