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
bcf87843
Commit
bcf87843
authored
Dec 19, 2014
by
Brendan Burns
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3048 from saad-ali/3002
Fix Issue #3002: kubectl get pods/log podname don't work well together
parents
5bd560de
0db4b8e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
17 deletions
+37
-17
resource_printer.go
pkg/kubectl/resource_printer.go
+37
-17
No files found.
pkg/kubectl/resource_printer.go
View file @
bcf87843
...
@@ -188,8 +188,8 @@ func (h *HumanReadablePrinter) validatePrintHandlerFunc(printFunc reflect.Value)
...
@@ -188,8 +188,8 @@ func (h *HumanReadablePrinter) validatePrintHandlerFunc(printFunc reflect.Value)
return
nil
return
nil
}
}
var
podColumns
=
[]
string
{
"
NAME
"
,
"IMAGE(S)"
,
"HOST"
,
"LABELS"
,
"STATUS"
}
var
podColumns
=
[]
string
{
"
POD"
,
"CONTAINER(S)
"
,
"IMAGE(S)"
,
"HOST"
,
"LABELS"
,
"STATUS"
}
var
replicationControllerColumns
=
[]
string
{
"
NAME
"
,
"IMAGE(S)"
,
"SELECTOR"
,
"REPLICAS"
}
var
replicationControllerColumns
=
[]
string
{
"
CONTROLLER"
,
"CONTAINER(S)
"
,
"IMAGE(S)"
,
"SELECTOR"
,
"REPLICAS"
}
var
serviceColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"SELECTOR"
,
"IP"
,
"PORT"
}
var
serviceColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"SELECTOR"
,
"IP"
,
"PORT"
}
var
minionColumns
=
[]
string
{
"NAME"
,
"LABELS"
}
var
minionColumns
=
[]
string
{
"NAME"
,
"LABELS"
}
var
statusColumns
=
[]
string
{
"STATUS"
}
var
statusColumns
=
[]
string
{
"STATUS"
}
...
@@ -235,22 +235,24 @@ func printPod(pod *api.Pod, w io.Writer) error {
...
@@ -235,22 +235,24 @@ func printPod(pod *api.Pod, w io.Writer) error {
if
err
:=
api
.
Scheme
.
Convert
(
&
pod
.
Spec
,
spec
);
err
!=
nil
{
if
err
:=
api
.
Scheme
.
Convert
(
&
pod
.
Spec
,
spec
);
err
!=
nil
{
glog
.
Errorf
(
"Unable to convert pod manifest: %v"
,
err
)
glog
.
Errorf
(
"Unable to convert pod manifest: %v"
,
err
)
}
}
il
:=
listOfImages
(
spec
)
containers
:=
spec
.
Containers
// Be paranoid about the case where there is no image.
var
firstContainer
api
.
Container
var
firstImage
string
if
len
(
containers
)
>
0
{
if
len
(
il
)
>
0
{
firstContainer
,
containers
=
containers
[
0
],
containers
[
1
:
]
firstImage
,
il
=
il
[
0
],
il
[
1
:
]
}
}
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\n
"
,
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\n
"
,
pod
.
Name
,
firstImage
,
pod
.
Name
,
firstContainer
.
Name
,
firstContainer
.
Image
,
podHostString
(
pod
.
Status
.
Host
,
pod
.
Status
.
HostIP
),
podHostString
(
pod
.
Status
.
Host
,
pod
.
Status
.
HostIP
),
formatLabels
(
pod
.
Labels
),
pod
.
Status
.
Phase
)
formatLabels
(
pod
.
Labels
),
pod
.
Status
.
Phase
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
// Lay out all the other
image
s on separate lines.
// Lay out all the other
container
s on separate lines.
for
_
,
image
:=
range
il
{
for
_
,
container
:=
range
containers
{
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\
n
"
,
""
,
i
mage
,
""
,
""
,
""
)
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\
t
%s
\n
"
,
""
,
container
.
Name
,
container
.
I
mage
,
""
,
""
,
""
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -268,10 +270,28 @@ func printPodList(podList *api.PodList, w io.Writer) error {
...
@@ -268,10 +270,28 @@ func printPodList(podList *api.PodList, w io.Writer) error {
}
}
func
printReplicationController
(
controller
*
api
.
ReplicationController
,
w
io
.
Writer
)
error
{
func
printReplicationController
(
controller
*
api
.
ReplicationController
,
w
io
.
Writer
)
error
{
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%d
\n
"
,
containers
:=
controller
.
Spec
.
Template
.
Spec
.
Containers
controller
.
Name
,
makeImageList
(
&
controller
.
Spec
.
Template
.
Spec
),
var
firstContainer
api
.
Container
formatLabels
(
controller
.
Spec
.
Selector
),
controller
.
Spec
.
Replicas
)
if
len
(
containers
)
>
0
{
return
err
firstContainer
,
containers
=
containers
[
0
],
containers
[
1
:
]
}
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%d
\n
"
,
controller
.
Name
,
firstContainer
.
Name
,
firstContainer
.
Image
,
formatLabels
(
controller
.
Spec
.
Selector
),
controller
.
Spec
.
Replicas
)
if
err
!=
nil
{
return
err
}
// Lay out all the other containers on separate lines.
for
_
,
container
:=
range
containers
{
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\n
"
,
""
,
container
.
Name
,
container
.
Image
,
""
,
""
)
if
err
!=
nil
{
return
err
}
}
return
nil
}
}
func
printReplicationControllerList
(
list
*
api
.
ReplicationControllerList
,
w
io
.
Writer
)
error
{
func
printReplicationControllerList
(
list
*
api
.
ReplicationControllerList
,
w
io
.
Writer
)
error
{
...
...
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