diff --git a/cmd/flux/create_helmrelease.go b/cmd/flux/create_helmrelease.go index d06e2ab3..a741cca8 100644 --- a/cmd/flux/create_helmrelease.go +++ b/cmd/flux/create_helmrelease.go @@ -309,7 +309,7 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error { } logger.Successf("HelmRelease %s is ready", name) - logger.Successf("applied revision %s", helmRelease.Status.LastAppliedRevision) + logger.Successf("applied revision %s", getHelmReleaseRevision(helmRelease)) return nil } diff --git a/cmd/flux/get_helmrelease.go b/cmd/flux/get_helmrelease.go index 92dc7215..034d11a6 100644 --- a/cmd/flux/get_helmrelease.go +++ b/cmd/flux/get_helmrelease.go @@ -72,9 +72,16 @@ func init() { getCmd.AddCommand(getHelmReleaseCmd) } +func getHelmReleaseRevision(helmRelease helmv2.HelmRelease) string { + if helmRelease.Status.History != nil && len(helmRelease.Status.History) > 0 { + return helmRelease.Status.History[0].ChartVersion + } + return helmRelease.Status.LastAttemptedRevision +} + func (a helmReleaseListAdapter) summariseItem(i int, includeNamespace bool, includeKind bool) []string { item := a.Items[i] - revision := item.Status.LastAppliedRevision + revision := getHelmReleaseRevision(item) status, msg := statusAndMessage(item.Status.Conditions) return append(nameColumns(&item, includeNamespace, includeKind), revision, cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) diff --git a/cmd/flux/resume_helmrelease.go b/cmd/flux/resume_helmrelease.go index 5c1bc15d..ecccaf46 100644 --- a/cmd/flux/resume_helmrelease.go +++ b/cmd/flux/resume_helmrelease.go @@ -55,7 +55,7 @@ func (obj helmReleaseAdapter) setUnsuspended() { } func (obj helmReleaseAdapter) successMessage() string { - return fmt.Sprintf("applied revision %s", obj.Status.LastAppliedRevision) + return fmt.Sprintf("applied revision %s", getHelmReleaseRevision(*obj.HelmRelease)) } func (a helmReleaseListAdapter) resumeItem(i int) resumable { diff --git a/cmd/flux/testdata/trace/deployment.yaml b/cmd/flux/testdata/trace/deployment.yaml index 0d0f8f79..a71fbd8a 100644 --- a/cmd/flux/testdata/trace/deployment.yaml +++ b/cmd/flux/testdata/trace/deployment.yaml @@ -59,11 +59,9 @@ status: status: "True" type: Ready helmChart: {{ .fluxns }}/podinfo-podinfo - lastAppliedRevision: 6.3.5 lastAttemptedRevision: 6.3.5 - lastAttemptedValuesChecksum: c31db75d05b7515eba2eef47bd71038c74b2e531 --- -apiVersion: source.toolkit.fluxcd.io/v1beta2 +apiVersion: source.toolkit.fluxcd.io/v1 kind: HelmChart metadata: name: podinfo-podinfo @@ -90,7 +88,7 @@ status: type: Ready --- -apiVersion: source.toolkit.fluxcd.io/v1beta2 +apiVersion: source.toolkit.fluxcd.io/v1 kind: HelmRepository metadata: labels: @@ -126,7 +124,6 @@ spec: sourceRef: kind: GitRepository name: flux-system - validation: client interval: 5m prune: true status: diff --git a/cmd/flux/trace.go b/cmd/flux/trace.go index 89094eed..7014bead 100644 --- a/cmd/flux/trace.go +++ b/cmd/flux/trace.go @@ -448,7 +448,7 @@ Namespace: {{.HelmRelease.Namespace}} {{- if .HelmRelease.Spec.TargetNamespace }} Target: {{.HelmRelease.Spec.TargetNamespace}} {{- end }} -Revision: {{.HelmRelease.Status.LastAppliedRevision}} +Revision: {{.HelmRelease.Status.LastAttemptedRevision}} {{- if .HelmReleaseReady }} Status: Last reconciled at {{.HelmReleaseReady.LastTransitionTime}} Message: {{.HelmReleaseReady.Message}}