Repository: knative/client (go)

Issue:
kn service describe should show # of instances
Today `kn service describe` will show this in it's output:
```
Revisions:  
  100%  @latest (echo-yyhmp-6) [6] (4d)
```
The `[6]` is interesting. I believe that the generation number - or in user's terms, my version # of my app. That's (sort of) interesting, but at first I thought it was the # of instances of this Revision that were running... that would be far more useful to me.

Proposal: show the # of instances of each revision instead of the generation #. I'm not really sure what the generation # tells the user, or what interesting thing they can do with it. It seems to me that seeing the revision name change in that list would be enough to indicate that there are multiple revisions out there.

This may be controversial because it means using a non-knative api (e.g. pods, or deployment) but I think we need to think about what's best (and most useful) for the user, and I think being able to see how their app is scaling (perhaps out of control!) would be very useful. 

We could even make it conditional, and try to get the list number of instances and if it fails due to an known API then just not show it (and no error msg), but if the API is there then show the info.

Pull request:
Add number of instances to describe command
## Description

Currently the Status fields `ActualReplicas,DesiredReplicas` are set to `omitempty`. Therefore the current impl doesn't show any replica details if both values are `0`.


```
➜  client git:(main) ✗ kn service describe hello                 
Name:       hello
Namespace:  default
Age:        34s
URL:        http://hello.default.127.0.0.1.nip.io

Revisions:  
  100%  @latest (hello-00001) [1] (34s)
        Image:     docker.io/dsimansk/helloworld (pinned to 29f975)
        Replicas:  1/1

Conditions:  
  OK TYPE                   AGE REASON
  ++ Ready                  20s 
  ++ ConfigurationsReady    29s 
  ++ RoutesReady            20s 
```

## Changes

<!-- Please add list of more detailed changes. These changes should be reflected also in the commit messages -->

* Add number of instances (`Replicas:`) to `kn service describe`
* Add number of instances (`Replicas:`) to `kn revision describe`


## Reference

<!-- Please add the corresponding issue number which this pull request is about to fix -->
Fixes #842 


/assign @knative/client-reviewers 


Patch:
diff --git a/pkg/kn/commands/revision/describe.go b/pkg/kn/commands/revision/describe.go
index e243d5de..9530b1d2 100644
--- a/pkg/kn/commands/revision/describe.go
+++ b/pkg/kn/commands/revision/describe.go
@@ -96,6 +96,7 @@ func describe(w io.Writer, revision *servingv1.Revision, service *servingv1.Serv
 	dw := printers.NewPrefixWriter(w)
 	commands.WriteMetadata(dw, &revision.ObjectMeta, printDetails)
 	WriteImage(dw, revision)
+	WriteReplicas(dw, revision)
 	WritePort(dw, revision)
 	WriteEnv(dw, revision, printDetails)
 	WriteEnvFrom(dw, revision, printDetails)
@@ -202,6 +203,14 @@ func WriteEnvFrom(dw printers.PrefixWriter, revision *servingv1.Revision, printD
 	}
 }
 
+func WriteReplicas(dw printers.PrefixWriter, revision *servingv1.Revision) {
+	actualReplicas := revision.Status.ActualReplicas
+	desiredReplicas := revision.Status.DesiredReplicas
+	if actualReplicas != 0 || desiredReplicas != 0 {
+		dw.WriteAttribute("Replicas", fmt.Sprintf("%d/%d", actualReplicas, desiredReplicas))
+	}
+}
+
 func WriteScale(dw printers.PrefixWriter, revision *servingv1.Revision) {
 	// Scale spec if given
 	scale, err := clientserving.ScalingInfo(&revision.ObjectMeta)
diff --git a/pkg/kn/commands/service/describe.go b/pkg/kn/commands/service/describe.go
index d9793bce..58df0e8b 100644
--- a/pkg/kn/commands/service/describe.go
+++ b/pkg/kn/commands/service/describe.go
@@ -221,6 +221,7 @@ func writeRevisions(dw printers.PrefixWriter, revisions []*revisionDesc, printDe
 			section.WriteAttribute("Error", ready.Reason)
 		}
 		revision.WriteImage(section, revisionDesc.revision)
+		revision.WriteReplicas(section, revisionDesc.revision)
 		if printDetails {
 			revision.WritePort(section, revisionDesc.revision)
 			revision.WriteEnv(section, revisionDesc.revision, printDetails)


Test patch:
diff --git a/pkg/kn/commands/revision/describe_test.go b/pkg/kn/commands/revision/describe_test.go
index a908ae04..a903caf5 100644
--- a/pkg/kn/commands/revision/describe_test.go
+++ b/pkg/kn/commands/revision/describe_test.go
@@ -120,6 +120,7 @@ func TestDescribeRevisionBasic(t *testing.T) {
 	}
 
 	assert.Assert(t, util.ContainsAll(data, "Image:", "gcr.io/test/image", "++ Ready", "Port:", "8080"))
+	assert.Assert(t, util.ContainsAll(data, "Replicas:", "0/1"))
 	assert.Assert(t, util.ContainsAll(data, "EnvFrom:", "cm:test1, cm:test2"))
 }
 
@@ -161,6 +162,8 @@ func createTestRevision(revision string, gen int64) servingv1.Revision {
 			},
 		},
 		Status: servingv1.RevisionStatus{
+			ActualReplicas:        0,
+			DesiredReplicas:       1,
 			DeprecatedImageDigest: "gcr.io/test/image@" + imageDigest,
 			Status: duckv1.Status{
 				Conditions: goodConditions(),
diff --git a/pkg/kn/commands/service/describe_test.go b/pkg/kn/commands/service/describe_test.go
index 376e17d1..5ea4a22d 100644
--- a/pkg/kn/commands/service/describe_test.go
+++ b/pkg/kn/commands/service/describe_test.go
@@ -68,6 +68,7 @@ func TestServiceDescribeBasic(t *testing.T) {
 	assert.Assert(t, util.ContainsAll(output, "Labels:", "label1=lval1, label2=lval2\n"))
 	assert.Assert(t, util.ContainsAll(output, "[1]"))
 	assert.Assert(t, cmp.Regexp("Service Account: \\s+default-sa", output))
+	assert.Assert(t, util.ContainsAll(output, "Replicas:", "0/1"))
 
 	assert.Equal(t, strings.Count(output, "rev1"), 1)
 
@@ -762,6 +763,8 @@ func createTestRevision(revision string, gen int64, conditions duckv1.Conditions
 			},
 		},
 		Status: servingv1.RevisionStatus{
+			ActualReplicas:        0,
+			DesiredReplicas:       1,
 			DeprecatedImageDigest: "gcr.io/test/image@" + imageDigest,
 			Status: duckv1.Status{
 				Conditions: conditions,