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
8c0c7626
Commit
8c0c7626
authored
May 30, 2017
by
Ricky Pai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ContainerRuntimeVersion to `kubectl get nodes -o=wide` output
parent
68dd748b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
printers.go
pkg/printers/internalversion/printers.go
+6
-3
printers_test.go
pkg/printers/internalversion/printers_test.go
+45
-0
No files found.
pkg/printers/internalversion/printers.go
View file @
8c0c7626
...
@@ -71,7 +71,7 @@ var (
...
@@ -71,7 +71,7 @@ var (
statefulSetColumns
=
[]
string
{
"NAME"
,
"DESIRED"
,
"CURRENT"
,
"AGE"
}
statefulSetColumns
=
[]
string
{
"NAME"
,
"DESIRED"
,
"CURRENT"
,
"AGE"
}
endpointColumns
=
[]
string
{
"NAME"
,
"ENDPOINTS"
,
"AGE"
}
endpointColumns
=
[]
string
{
"NAME"
,
"ENDPOINTS"
,
"AGE"
}
nodeColumns
=
[]
string
{
"NAME"
,
"STATUS"
,
"AGE"
,
"VERSION"
}
nodeColumns
=
[]
string
{
"NAME"
,
"STATUS"
,
"AGE"
,
"VERSION"
}
nodeWideColumns
=
[]
string
{
"EXTERNAL-IP"
,
"OS-IMAGE"
,
"KERNEL-VERSION"
}
nodeWideColumns
=
[]
string
{
"EXTERNAL-IP"
,
"OS-IMAGE"
,
"KERNEL-VERSION"
,
"CONTAINER-RUNTIME"
}
daemonSetColumns
=
[]
string
{
"NAME"
,
"DESIRED"
,
"CURRENT"
,
"READY"
,
"UP-TO-DATE"
,
"AVAILABLE"
,
"NODE-SELECTOR"
,
"AGE"
}
daemonSetColumns
=
[]
string
{
"NAME"
,
"DESIRED"
,
"CURRENT"
,
"READY"
,
"UP-TO-DATE"
,
"AVAILABLE"
,
"NODE-SELECTOR"
,
"AGE"
}
daemonSetWideColumns
=
[]
string
{
"CONTAINER(S)"
,
"IMAGE(S)"
,
"SELECTOR"
}
daemonSetWideColumns
=
[]
string
{
"CONTAINER(S)"
,
"IMAGE(S)"
,
"SELECTOR"
}
eventColumns
=
[]
string
{
"LASTSEEN"
,
"FIRSTSEEN"
,
"COUNT"
,
"NAME"
,
"KIND"
,
"SUBOBJECT"
,
"TYPE"
,
"REASON"
,
"SOURCE"
,
"MESSAGE"
}
eventColumns
=
[]
string
{
"LASTSEEN"
,
"FIRSTSEEN"
,
"COUNT"
,
"NAME"
,
"KIND"
,
"SUBOBJECT"
,
"TYPE"
,
"REASON"
,
"SOURCE"
,
"MESSAGE"
}
...
@@ -1127,14 +1127,17 @@ func printNode(node *api.Node, w io.Writer, options printers.PrintOptions) error
...
@@ -1127,14 +1127,17 @@ func printNode(node *api.Node, w io.Writer, options printers.PrintOptions) error
}
}
if
options
.
Wide
{
if
options
.
Wide
{
osImage
,
kernelVersion
:=
node
.
Status
.
NodeInfo
.
OSImage
,
node
.
Status
.
NodeInfo
.
Kernel
Version
osImage
,
kernelVersion
,
crVersion
:=
node
.
Status
.
NodeInfo
.
OSImage
,
node
.
Status
.
NodeInfo
.
KernelVersion
,
node
.
Status
.
NodeInfo
.
ContainerRuntime
Version
if
osImage
==
""
{
if
osImage
==
""
{
osImage
=
"<unknown>"
osImage
=
"<unknown>"
}
}
if
kernelVersion
==
""
{
if
kernelVersion
==
""
{
kernelVersion
=
"<unknown>"
kernelVersion
=
"<unknown>"
}
}
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"
\t
%s
\t
%s
\t
%s"
,
getNodeExternalIP
(
node
),
osImage
,
kernelVersion
);
err
!=
nil
{
if
crVersion
==
""
{
crVersion
=
"<unknown>"
}
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"
\t
%s
\t
%s
\t
%s
\t
%s"
,
getNodeExternalIP
(
node
),
osImage
,
kernelVersion
,
crVersion
);
err
!=
nil
{
return
err
return
err
}
}
}
}
...
...
pkg/printers/internalversion/printers_test.go
View file @
8c0c7626
...
@@ -826,6 +826,51 @@ func TestPrintNodeKernelVersion(t *testing.T) {
...
@@ -826,6 +826,51 @@ func TestPrintNodeKernelVersion(t *testing.T) {
}
}
}
}
func
TestPrintNodeContainerRuntimeVersion
(
t
*
testing
.
T
)
{
printer
:=
printers
.
NewHumanReadablePrinter
(
nil
,
nil
,
printers
.
PrintOptions
{
ColumnLabels
:
[]
string
{},
Wide
:
true
,
})
AddHandlers
(
printer
)
table
:=
[]
struct
{
node
api
.
Node
containerRuntimeVersion
string
}{
{
node
:
api
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo1"
},
Status
:
api
.
NodeStatus
{
NodeInfo
:
api
.
NodeSystemInfo
{
ContainerRuntimeVersion
:
"foo://1.2.3"
},
Addresses
:
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeExternalIP
,
Address
:
"1.1.1.1"
}},
},
},
containerRuntimeVersion
:
"foo://1.2.3"
,
},
{
node
:
api
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo2"
},
Status
:
api
.
NodeStatus
{
NodeInfo
:
api
.
NodeSystemInfo
{},
Addresses
:
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeExternalIP
,
Address
:
"1.1.1.1"
}},
},
},
containerRuntimeVersion
:
"<unknown>"
,
},
}
for
_
,
test
:=
range
table
{
buffer
:=
&
bytes
.
Buffer
{}
err
:=
printer
.
PrintObj
(
&
test
.
node
,
buffer
)
if
err
!=
nil
{
t
.
Fatalf
(
"An error occurred printing Node: %#v"
,
err
)
}
if
!
contains
(
strings
.
Fields
(
buffer
.
String
()),
test
.
containerRuntimeVersion
)
{
t
.
Fatalf
(
"Expect printing node %s with kernel version %#v, got: %#v"
,
test
.
node
.
Name
,
test
.
containerRuntimeVersion
,
buffer
.
String
())
}
}
}
func
TestPrintNodeName
(
t
*
testing
.
T
)
{
func
TestPrintNodeName
(
t
*
testing
.
T
)
{
printer
:=
printers
.
NewHumanReadablePrinter
(
nil
,
nil
,
printers
.
PrintOptions
{
printer
:=
printers
.
NewHumanReadablePrinter
(
nil
,
nil
,
printers
.
PrintOptions
{
Wide
:
true
,
Wide
:
true
,
...
...
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