From f3cab6e1771e6dda81099c84a76e7add10620a70 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Mon, 5 Oct 2020 18:05:11 +0200 Subject: [PATCH] Display proper revision for sources Includes a change to an empty revision string if the reconciler has not produced an artifact yet, as this will otherwise result in a nil pointer dereference. --- cmd/gotk/get_source_bucket.go | 10 +++++++--- cmd/gotk/get_source_git.go | 10 +++++++--- cmd/gotk/get_source_helm.go | 10 +++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/cmd/gotk/get_source_bucket.go b/cmd/gotk/get_source_bucket.go index c5d7d49c..e4323285 100644 --- a/cmd/gotk/get_source_bucket.go +++ b/cmd/gotk/get_source_bucket.go @@ -72,18 +72,22 @@ func getSourceBucketCmdRun(cmd *cobra.Command, args []string) error { } var rows [][]string for _, source := range list.Items { - row := []string{} + var row []string + var revision string + if source.GetArtifact() != nil { + revision = source.GetArtifact().Revision + } if c := meta.GetCondition(source.Status.Conditions, meta.ReadyCondition); c != nil { row = []string{ source.GetName(), - source.GetArtifact().Revision, + revision, string(c.Status), c.Message, } } else { row = []string{ source.GetName(), - source.GetArtifact().Revision, + revision, string(corev1.ConditionFalse), "waiting to be reconciled", } diff --git a/cmd/gotk/get_source_git.go b/cmd/gotk/get_source_git.go index 3addb4d1..4afe14fb 100644 --- a/cmd/gotk/get_source_git.go +++ b/cmd/gotk/get_source_git.go @@ -72,18 +72,22 @@ func getSourceGitCmdRun(cmd *cobra.Command, args []string) error { } var rows [][]string for _, source := range list.Items { - row := []string{} + var row []string + var revision string + if source.GetArtifact() != nil { + revision = source.GetArtifact().Revision + } if c := meta.GetCondition(source.Status.Conditions, meta.ReadyCondition); c != nil { row = []string{ source.GetName(), - "unknown", + revision, string(c.Status), c.Message, } } else { row = []string{ source.GetName(), - source.GetArtifact().Revision, + revision, string(corev1.ConditionFalse), "waiting to be reconciled", } diff --git a/cmd/gotk/get_source_helm.go b/cmd/gotk/get_source_helm.go index 7401263b..10e3b2b1 100644 --- a/cmd/gotk/get_source_helm.go +++ b/cmd/gotk/get_source_helm.go @@ -72,18 +72,22 @@ func getSourceHelmCmdRun(cmd *cobra.Command, args []string) error { } var rows [][]string for _, source := range list.Items { - row := []string{} + var row []string + var revision string + if source.GetArtifact() != nil { + revision = source.GetArtifact().Revision + } if c := meta.GetCondition(source.Status.Conditions, meta.ReadyCondition); c != nil { row = []string{ source.GetName(), - source.GetArtifact().Revision, + revision, string(c.Status), c.Message, } } else { row = []string{ source.GetName(), - source.GetArtifact().Revision, + revision, string(corev1.ConditionFalse), "waiting to be reconciled", }