kubectl: display ready replicas in 'get {rs,rc}'

pull/6/head
Michail Kargakis 2016-08-18 11:35:18 +02:00
parent 878e06a71c
commit 51a894e616
2 changed files with 16 additions and 11 deletions

View File

@ -420,7 +420,8 @@ func Example_printReplicationControllerWithNamespace() {
}, },
}, },
Status: api.ReplicationControllerStatus{ Status: api.ReplicationControllerStatus{
Replicas: 1, Replicas: 1,
ReadyReplicas: 1,
}, },
} }
mapper, _ := f.Object(false) mapper, _ := f.Object(false)
@ -429,8 +430,8 @@ func Example_printReplicationControllerWithNamespace() {
fmt.Printf("Unexpected error: %v", err) fmt.Printf("Unexpected error: %v", err)
} }
// Output: // Output:
// NAMESPACE NAME DESIRED CURRENT AGE // NAMESPACE NAME DESIRED CURRENT READY AGE
// beep foo 1 1 10y // beep foo 1 1 1 10y
} }
func Example_printMultiContainersReplicationControllerWithWide() { func Example_printMultiContainersReplicationControllerWithWide() {
@ -481,8 +482,8 @@ func Example_printMultiContainersReplicationControllerWithWide() {
fmt.Printf("Unexpected error: %v", err) fmt.Printf("Unexpected error: %v", err)
} }
// Output: // Output:
// NAME DESIRED CURRENT AGE CONTAINER(S) IMAGE(S) SELECTOR // NAME DESIRED CURRENT READY AGE CONTAINER(S) IMAGE(S) SELECTOR
// foo 1 1 10y foo,foo2 someimage,someimage2 foo=bar // foo 1 1 0 10y foo,foo2 someimage,someimage2 foo=bar
} }
func Example_printReplicationController() { func Example_printReplicationController() {
@ -532,8 +533,8 @@ func Example_printReplicationController() {
fmt.Printf("Unexpected error: %v", err) fmt.Printf("Unexpected error: %v", err)
} }
// Output: // Output:
// NAME DESIRED CURRENT AGE // NAME DESIRED CURRENT READY AGE
// foo 1 1 10y // foo 1 1 0 10y
} }
func Example_printPodWithWideFormat() { func Example_printPodWithWideFormat() {

View File

@ -458,8 +458,8 @@ func (h *HumanReadablePrinter) FinishPrint(output io.Writer, res string) error {
// pkg/kubectl/cmd/get.go to reflect the new resource type. // pkg/kubectl/cmd/get.go to reflect the new resource type.
var podColumns = []string{"NAME", "READY", "STATUS", "RESTARTS", "AGE"} var podColumns = []string{"NAME", "READY", "STATUS", "RESTARTS", "AGE"}
var podTemplateColumns = []string{"TEMPLATE", "CONTAINER(S)", "IMAGE(S)", "PODLABELS"} var podTemplateColumns = []string{"TEMPLATE", "CONTAINER(S)", "IMAGE(S)", "PODLABELS"}
var replicationControllerColumns = []string{"NAME", "DESIRED", "CURRENT", "AGE"} var replicationControllerColumns = []string{"NAME", "DESIRED", "CURRENT", "READY", "AGE"}
var replicaSetColumns = []string{"NAME", "DESIRED", "CURRENT", "AGE"} var replicaSetColumns = []string{"NAME", "DESIRED", "CURRENT", "READY", "AGE"}
var jobColumns = []string{"NAME", "DESIRED", "SUCCESSFUL", "AGE"} var jobColumns = []string{"NAME", "DESIRED", "SUCCESSFUL", "AGE"}
var scheduledJobColumns = []string{"NAME", "SCHEDULE", "SUSPEND", "ACTIVE", "LAST-SCHEDULE"} var scheduledJobColumns = []string{"NAME", "SCHEDULE", "SUSPEND", "ACTIVE", "LAST-SCHEDULE"}
var serviceColumns = []string{"NAME", "CLUSTER-IP", "EXTERNAL-IP", "PORT(S)", "AGE"} var serviceColumns = []string{"NAME", "CLUSTER-IP", "EXTERNAL-IP", "PORT(S)", "AGE"}
@ -834,10 +834,12 @@ func printReplicationController(controller *api.ReplicationController, w io.Writ
desiredReplicas := controller.Spec.Replicas desiredReplicas := controller.Spec.Replicas
currentReplicas := controller.Status.Replicas currentReplicas := controller.Status.Replicas
if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%s", readyReplicas := controller.Status.ReadyReplicas
if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%d\t%s",
name, name,
desiredReplicas, desiredReplicas,
currentReplicas, currentReplicas,
readyReplicas,
translateTimestamp(controller.CreationTimestamp), translateTimestamp(controller.CreationTimestamp),
); err != nil { ); err != nil {
return err return err
@ -884,10 +886,12 @@ func printReplicaSet(rs *extensions.ReplicaSet, w io.Writer, options PrintOption
desiredReplicas := rs.Spec.Replicas desiredReplicas := rs.Spec.Replicas
currentReplicas := rs.Status.Replicas currentReplicas := rs.Status.Replicas
if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%s", readyReplicas := rs.Status.ReadyReplicas
if _, err := fmt.Fprintf(w, "%s\t%d\t%d\t%d\t%s",
name, name,
desiredReplicas, desiredReplicas,
currentReplicas, currentReplicas,
readyReplicas,
translateTimestamp(rs.CreationTimestamp), translateTimestamp(rs.CreationTimestamp),
); err != nil { ); err != nil {
return err return err