Repository: knative/client
Pull request #1454 (2021-09-17 11:55:55)

Remove `DeprecatedImageDigest` field
## Description

Note to the reviewers: I'll open new issue to handle multi-container Revisions. Hence the PR uses only `ContainerStatus[0]` that should be equal to `DeprecatedImageDigest` by the following:
>// If multiple containers specified then DeprecatedImageDigest holds the digest
	// for serving container.

https://github.com/knative/serving/blob/d2461492bea18cde5f9aa0419c8fee24570782aa/pkg/apis/serving/v1/revision_types.go#L139-L151

## Changes

<!-- Please add list of more detailed changes. These changes should be reflected also in the commit messages -->

* 🐣 Remove `DeprecatedImageDigest` field


## Reference
Fixes failing auto update PR #1452.

knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/client/pull/1454#" title="Author self-approved">dsimansk</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fclient).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative/client/blob/main/OWNERS)~~ [dsimansk]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
codecov[bot]: # [Codecov](https://codecov.io/gh/knative/client/pull/1454?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative) Report
> Merging [#1454](https://codecov.io/gh/knative/client/pull/1454?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative) (35a9de7) into [main](https://codecov.io/gh/knative/client/commit/82a21a5773be7157f9b46c4c7f7946adbb23457b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative) (82a21a5) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/knative/client/pull/1454/graphs/tree.svg?width=650&height=150&src=pr&token=bkTp6BzJiV&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative)](https://codecov.io/gh/knative/client/pull/1454?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative)

```diff
@@           Coverage Diff           @@
##             main    #1454   +/-   ##
=======================================
  Coverage   78.98%   78.98%           
=======================================
  Files         162      162           
  Lines        8416     8416           
=======================================
  Hits         6647     6647           
  Misses       1088     1088           
  Partials      681      681           
```


| [Impacted Files](https://codecov.io/gh/knative/client/pull/1454?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative) | Coverage Δ | |
|---|---|---|
| [pkg/kn/commands/revision/describe.go](https://codecov.io/gh/knative/client/pull/1454/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative#diff-cGtnL2tuL2NvbW1hbmRzL3JldmlzaW9uL2Rlc2NyaWJlLmdv) | `50.61% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/knative/client/pull/1454?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/knative/client/pull/1454?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative). Last update [82a21a5...35a9de7](https://codecov.io/gh/knative/client/pull/1454?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative).

rhuss: /approve
/lgtm
knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/client/pull/1454#" title="Author self-approved">dsimansk</a>*, *<a href="https://github.com/knative/client/pull/1454#issuecomment-921796685" title="LGTM">rhuss</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fclient).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative/client/blob/main/OWNERS)~~ [dsimansk,rhuss]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/pkg/kn/commands/revision/describe.go b/pkg/kn/commands/revision/describe.go
index 42488ae6..346ad7ea 100644
--- a/pkg/kn/commands/revision/describe.go
+++ b/pkg/kn/commands/revision/describe.go
@@ -162,7 +162,7 @@ func WriteImage(dw printers.PrefixWriter, revision *servingv1.Revision) {
 	// Check if the user image is likely a more user-friendly description
 	pinnedDesc := "at"
 	userImage := clientserving.UserImage(&revision.ObjectMeta)
-	imageDigest := revision.Status.DeprecatedImageDigest
+	imageDigest := revision.Status.ContainerStatuses[0].ImageDigest
 	if userImage != "" && imageDigest != "" {
 		var parts []string
 		if strings.Contains(image, "@") {


Test patch:
diff --git a/pkg/kn/commands/revision/describe_test.go b/pkg/kn/commands/revision/describe_test.go
index e06a04e6..bb09ff96 100644
--- a/pkg/kn/commands/revision/describe_test.go
+++ b/pkg/kn/commands/revision/describe_test.go
@@ -182,9 +182,11 @@ func createTestRevision(revision string, gen int64, replicas *int32) servingv1.R
 			},
 		},
 		Status: servingv1.RevisionStatus{
-			ActualReplicas:        replicas,
-			DesiredReplicas:       replicas,
-			DeprecatedImageDigest: "gcr.io/test/image@" + imageDigest,
+			ActualReplicas:  replicas,
+			DesiredReplicas: replicas,
+			ContainerStatuses: []servingv1.ContainerStatus{
+				{Name: "gcr.io/test/image", ImageDigest: 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 1be1faf6..d4930221 100644
--- a/pkg/kn/commands/service/describe_test.go
+++ b/pkg/kn/commands/service/describe_test.go
@@ -400,7 +400,9 @@ func TestServiceDescribeUserImageVsImage(t *testing.T) {
 	rev3.Annotations[client_serving.UserImageAnnotationKey] = "gcr.io/test/image:latest"
 	rev3.Spec.Containers[0].Image = "gcr.io/a/b"
 	// rev4 is without the annotation at all and no hash
-	rev4.Status.DeprecatedImageDigest = ""
+	rev4.Status.ContainerStatuses = []servingv1.ContainerStatus{
+		{Name: "gcr.io/x/y", ImageDigest: ""},
+	}
 	rev4.Spec.Containers[0].Image = "gcr.io/x/y"
 
 	// Fetch the revisions
@@ -763,9 +765,11 @@ func createTestRevision(revision string, gen int64, conditions duckv1.Conditions
 			},
 		},
 		Status: servingv1.RevisionStatus{
-			ActualReplicas:        ptr.Int32(0),
-			DesiredReplicas:       ptr.Int32(1),
-			DeprecatedImageDigest: "gcr.io/test/image@" + imageDigest,
+			ActualReplicas:  ptr.Int32(0),
+			DesiredReplicas: ptr.Int32(1),
+			ContainerStatuses: []servingv1.ContainerStatus{
+				{Name: "gcr.io/test/image", ImageDigest: imageDigest},
+			},
 			Status: duckv1.Status{
 				Conditions: conditions,
 			},
diff --git a/pkg/kn/commands/service/update_test.go b/pkg/kn/commands/service/update_test.go
index dd2037ea..d344759f 100644
--- a/pkg/kn/commands/service/update_test.go
+++ b/pkg/kn/commands/service/update_test.go
@@ -96,8 +96,6 @@ func fakeServiceUpdate(original *servingv1.Service, args []string) (
 			rev.Status.ContainerStatuses = []servingv1.ContainerStatus{
 				{ImageDigest: exampleImageByDigest, Name: "user-container"},
 			}
-
-			rev.Status.DeprecatedImageDigest = exampleImageByDigest
 			return true, rev, nil
 		})