Fixed panic in kn service describe (#1529)

* Fixed panic in kn service describe

* Added changelog entry

* Update CHANGELOG.adoc

Co-authored-by: David Simansky <dsimansk@redhat.com>

Co-authored-by: David Simansky <dsimansk@redhat.com>
This commit is contained in:
Gunjan Vyas 2021-11-23 21:19:50 +05:30 committed by GitHub
parent 5eb1ecefdc
commit 4316d0345f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -12,6 +12,17 @@
| https://github.com/knative/client/pull/[#] | https://github.com/knative/client/pull/[#]
//// ////
## v1.1.0 (Unreleased)
[cols="1,10,3", options="header", width="100%"]
|===
| | Description | PR
| 🐛
| Fixed panic in kn service describe
| https://github.com/knative/client/pull/1529[#1529]
|===
## v1.0.0 (2021-11-02) ## v1.0.0 (2021-11-02)
[cols="1,10,3", options="header", width="100%"] [cols="1,10,3", options="header", width="100%"]
|=== |===

View File

@ -162,7 +162,12 @@ func WriteImage(dw printers.PrefixWriter, revision *servingv1.Revision) {
// Check if the user image is likely a more user-friendly description // Check if the user image is likely a more user-friendly description
pinnedDesc := "at" pinnedDesc := "at"
userImage := clientserving.UserImage(&revision.ObjectMeta) userImage := clientserving.UserImage(&revision.ObjectMeta)
imageDigest := revision.Status.ContainerStatuses[0].ImageDigest
containerStatuses := revision.Status.ContainerStatuses
var imageDigest string
if len(containerStatuses) > 0 {
imageDigest = containerStatuses[0].ImageDigest
}
if userImage != "" && imageDigest != "" { if userImage != "" && imageDigest != "" {
var parts []string var parts []string
if strings.Contains(image, "@") { if strings.Contains(image, "@") {