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
aa5c036a
Commit
aa5c036a
authored
Feb 23, 2016
by
AdoHe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add DESIRED and CURRENT columns to rcs,ds,rs
parent
a89b607a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
12 deletions
+66
-12
cmd_test.go
pkg/kubectl/cmd/cmd_test.go
+10
-4
resource_printer.go
pkg/kubectl/resource_printer.go
+21
-8
resource_printer_test.go
pkg/kubectl/resource_printer_test.go
+35
-0
No files found.
pkg/kubectl/cmd/cmd_test.go
View file @
aa5c036a
...
...
@@ -357,14 +357,17 @@ func ExamplePrintReplicationControllerWithNamespace() {
},
},
},
Status
:
api
.
ReplicationControllerStatus
{
Replicas
:
1
,
},
}
err
:=
f
.
PrintObject
(
cmd
,
ctrl
,
os
.
Stdout
)
if
err
!=
nil
{
fmt
.
Printf
(
"Unexpected error: %v"
,
err
)
}
// Output:
// NAMESPACE NAME
REPLICAS
AGE
// beep foo 1 10y
// NAMESPACE NAME
DESIRED CURRENT
AGE
// beep foo 1
1
10y
}
func
ExamplePrintReplicationControllerWithWide
()
{
...
...
@@ -398,14 +401,17 @@ func ExamplePrintReplicationControllerWithWide() {
},
},
},
Status
:
api
.
ReplicationControllerStatus
{
Replicas
:
1
,
},
}
err
:=
f
.
PrintObject
(
cmd
,
ctrl
,
os
.
Stdout
)
if
err
!=
nil
{
fmt
.
Printf
(
"Unexpected error: %v"
,
err
)
}
// Output:
// NAME
REPLICAS
AGE CONTAINER(S) IMAGE(S) SELECTOR
// foo 1 10y foo someimage foo=bar
// NAME
DESIRED CURRENT
AGE CONTAINER(S) IMAGE(S) SELECTOR
// foo 1
1
10y foo someimage foo=bar
}
func
ExamplePrintPodWithWideFormat
()
{
...
...
pkg/kubectl/resource_printer.go
View file @
aa5c036a
...
...
@@ -396,14 +396,14 @@ func (h *HumanReadablePrinter) HandledResources() []string {
// pkg/kubectl/cmd/get.go to reflect the new resource type.
var
podColumns
=
[]
string
{
"NAME"
,
"READY"
,
"STATUS"
,
"RESTARTS"
,
"AGE"
}
var
podTemplateColumns
=
[]
string
{
"TEMPLATE"
,
"CONTAINER(S)"
,
"IMAGE(S)"
,
"PODLABELS"
}
var
replicationControllerColumns
=
[]
string
{
"NAME"
,
"
REPLICAS
"
,
"AGE"
}
var
replicaSetColumns
=
[]
string
{
"NAME"
,
"
REPLICAS
"
,
"AGE"
}
var
replicationControllerColumns
=
[]
string
{
"NAME"
,
"
DESIRED"
,
"CURRENT
"
,
"AGE"
}
var
replicaSetColumns
=
[]
string
{
"NAME"
,
"
DESIRED"
,
"CURRENT
"
,
"AGE"
}
var
jobColumns
=
[]
string
{
"NAME"
,
"SUCCESSFUL"
}
var
serviceColumns
=
[]
string
{
"NAME"
,
"CLUSTER-IP"
,
"EXTERNAL-IP"
,
"PORT(S)"
,
"AGE"
}
var
ingressColumns
=
[]
string
{
"NAME"
,
"RULE"
,
"BACKEND"
,
"ADDRESS"
}
var
endpointColumns
=
[]
string
{
"NAME"
,
"ENDPOINTS"
,
"AGE"
}
var
nodeColumns
=
[]
string
{
"NAME"
,
"STATUS"
,
"AGE"
}
var
daemonSetColumns
=
[]
string
{
"NAME"
,
"NODE-SELECTOR"
}
var
daemonSetColumns
=
[]
string
{
"NAME"
,
"
DESIRED"
,
"CURRENT"
,
"
NODE-SELECTOR"
}
var
eventColumns
=
[]
string
{
"FIRSTSEEN"
,
"LASTSEEN"
,
"COUNT"
,
"NAME"
,
"KIND"
,
"SUBOBJECT"
,
"TYPE"
,
"REASON"
,
"SOURCE"
,
"MESSAGE"
}
var
limitRangeColumns
=
[]
string
{
"NAME"
,
"AGE"
}
var
resourceQuotaColumns
=
[]
string
{
"NAME"
,
"AGE"
}
...
...
@@ -703,9 +703,13 @@ func printReplicationController(controller *api.ReplicationController, w io.Writ
return
err
}
}
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%d
\t
%s"
,
desiredReplicas
:=
controller
.
Spec
.
Replicas
currentReplicas
:=
controller
.
Status
.
Replicas
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%d
\t
%d
\t
%s"
,
name
,
controller
.
Spec
.
Replicas
,
desiredReplicas
,
currentReplicas
,
translateTimestamp
(
controller
.
CreationTimestamp
),
);
err
!=
nil
{
return
err
...
...
@@ -766,9 +770,13 @@ func printReplicaSet(rs *extensions.ReplicaSet, w io.Writer, options PrintOption
return
err
}
}
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%d
\t
%s"
,
desiredReplicas
:=
rs
.
Spec
.
Replicas
currentReplicas
:=
rs
.
Status
.
Replicas
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%d
\t
%d
\t
%s"
,
name
,
rs
.
Spec
.
Replicas
,
desiredReplicas
,
currentReplicas
,
translateTimestamp
(
rs
.
CreationTimestamp
),
);
err
!=
nil
{
return
err
...
...
@@ -1051,13 +1059,18 @@ func printDaemonSet(ds *extensions.DaemonSet, w io.Writer, options PrintOptions)
return
err
}
}
desiredScheduled
:=
ds
.
Status
.
DesiredNumberScheduled
currentScheduled
:=
ds
.
Status
.
CurrentNumberScheduled
selector
,
err
:=
unversioned
.
LabelSelectorAsSelector
(
ds
.
Spec
.
Selector
)
if
err
!=
nil
{
// this shouldn't happen if LabelSelector passed validation
return
err
}
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s"
,
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%
d
\t
%d
\t
%
s"
,
name
,
desiredScheduled
,
currentScheduled
,
labels
.
FormatLabels
(
ds
.
Spec
.
Template
.
Spec
.
NodeSelector
),
);
err
!=
nil
{
return
err
...
...
pkg/kubectl/resource_printer_test.go
View file @
aa5c036a
...
...
@@ -1305,6 +1305,41 @@ func TestPrintDeployment(t *testing.T) {
}
}
func
TestPrintDaemonSet
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
ds
extensions
.
DaemonSet
startsWith
string
}{
{
extensions
.
DaemonSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"test1"
,
CreationTimestamp
:
unversioned
.
Time
{
Time
:
time
.
Now
()
.
Add
(
1.9e9
)},
},
Spec
:
extensions
.
DaemonSetSpec
{
Template
:
api
.
PodTemplateSpec
{
Spec
:
api
.
PodSpec
{
Containers
:
make
([]
api
.
Container
,
2
)},
},
},
Status
:
extensions
.
DaemonSetStatus
{
CurrentNumberScheduled
:
2
,
DesiredNumberScheduled
:
3
,
},
},
"test1
\t
3
\t
2
\t
<none>
\n
"
,
},
}
buf
:=
bytes
.
NewBuffer
([]
byte
{})
for
_
,
test
:=
range
tests
{
printDaemonSet
(
&
test
.
ds
,
buf
,
PrintOptions
{
false
,
false
,
false
,
false
,
false
,
false
,
[]
string
{}})
if
!
strings
.
HasPrefix
(
buf
.
String
(),
test
.
startsWith
)
{
t
.
Fatalf
(
"Expected to start with %s but got %s"
,
test
.
startsWith
,
buf
.
String
())
}
buf
.
Reset
()
}
}
func
TestPrintPodShowLabels
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
pod
api
.
Pod
...
...
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