From 863d3115f334be0baf910d86799c08b7ba253023 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Tue, 7 May 2024 08:33:52 +0300 Subject: [PATCH] Add app version to CRD manifests Signed-off-by: Stefan Prodan --- api/v2beta1/helmrelease_types.go | 3 ++- api/v2beta1/zz_generated.deepcopy.go | 5 +++-- api/v2beta2/helmrelease_types.go | 4 +++- api/v2beta2/zz_generated.deepcopy.go | 5 +++-- .../helm.toolkit.fluxcd.io_helmreleases.yaml | 12 +++++++++-- docs/api/v2/helm.md | 20 +++++++++---------- internal/reconcile/release.go | 10 ++++++---- 7 files changed, 37 insertions(+), 22 deletions(-) diff --git a/api/v2beta1/helmrelease_types.go b/api/v2beta1/helmrelease_types.go index f857baac0..6b241bced 100644 --- a/api/v2beta1/helmrelease_types.go +++ b/api/v2beta1/helmrelease_types.go @@ -29,6 +29,7 @@ import ( "github.com/fluxcd/pkg/apis/kustomize" "github.com/fluxcd/pkg/apis/meta" + v2 "github.com/fluxcd/helm-controller/api/v2" "github.com/fluxcd/helm-controller/api/v2beta2" ) @@ -931,7 +932,7 @@ type HelmReleaseStatus struct { // Note: this field is provisional to the v2beta2 API, and not actively used // by v2beta1 HelmReleases. // +optional - History v2beta2.Snapshots `json:"history,omitempty"` + History v2.Snapshots `json:"history,omitempty"` // LastAttemptedGeneration is the last generation the controller attempted // to reconcile. diff --git a/api/v2beta1/zz_generated.deepcopy.go b/api/v2beta1/zz_generated.deepcopy.go index 69eea9950..f985bf87b 100644 --- a/api/v2beta1/zz_generated.deepcopy.go +++ b/api/v2beta1/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v2beta1 import ( + "github.com/fluxcd/helm-controller/api/v2" "github.com/fluxcd/helm-controller/api/v2beta2" "github.com/fluxcd/pkg/apis/kustomize" "github.com/fluxcd/pkg/apis/meta" @@ -306,11 +307,11 @@ func (in *HelmReleaseStatus) DeepCopyInto(out *HelmReleaseStatus) { } if in.History != nil { in, out := &in.History, &out.History - *out = make(v2beta2.Snapshots, len(*in)) + *out = make(v2.Snapshots, len(*in)) for i := range *in { if (*in)[i] != nil { in, out := &(*in)[i], &(*out)[i] - *out = new(v2beta2.Snapshot) + *out = new(v2.Snapshot) (*in).DeepCopyInto(*out) } } diff --git a/api/v2beta2/helmrelease_types.go b/api/v2beta2/helmrelease_types.go index 4f2121dad..03c693e48 100644 --- a/api/v2beta2/helmrelease_types.go +++ b/api/v2beta2/helmrelease_types.go @@ -27,6 +27,8 @@ import ( "github.com/fluxcd/pkg/apis/kustomize" "github.com/fluxcd/pkg/apis/meta" + + v2 "github.com/fluxcd/helm-controller/api/v2" ) const ( @@ -976,7 +978,7 @@ type HelmReleaseStatus struct { // History holds the history of Helm releases performed for this HelmRelease // up to the last successfully completed release. // +optional - History Snapshots `json:"history,omitempty"` + History v2.Snapshots `json:"history,omitempty"` // LastAttemptedReleaseAction is the last release action performed for this // HelmRelease. It is used to determine the active remediation strategy. diff --git a/api/v2beta2/zz_generated.deepcopy.go b/api/v2beta2/zz_generated.deepcopy.go index 2e5711694..6e97f139a 100644 --- a/api/v2beta2/zz_generated.deepcopy.go +++ b/api/v2beta2/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v2beta2 import ( + "github.com/fluxcd/helm-controller/api/v2" "github.com/fluxcd/pkg/apis/kustomize" "github.com/fluxcd/pkg/apis/meta" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" @@ -361,11 +362,11 @@ func (in *HelmReleaseStatus) DeepCopyInto(out *HelmReleaseStatus) { } if in.History != nil { in, out := &in.History, &out.History - *out = make(Snapshots, len(*in)) + *out = make(v2.Snapshots, len(*in)) for i := range *in { if (*in)[i] != nil { in, out := &(*in)[i], &(*out)[i] - *out = new(Snapshot) + *out = new(v2.Snapshot) (*in).DeepCopyInto(*out) } } diff --git a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml index 5762f49d0..685bb6e3e 100644 --- a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml +++ b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml @@ -1003,8 +1003,8 @@ spec: this field will be used to distinguish between the old and new methods. type: string appVersion: - description: Version is the version of the release object in - storage. + description: AppVersion is the chart app version of the release + object in storage. type: string chartName: description: ChartName is the chart name of the release object @@ -2224,6 +2224,10 @@ spec: Provisional: when the calculation method of the Digest field is changed, this field will be used to distinguish between the old and new methods. type: string + appVersion: + description: AppVersion is the chart app version of the release + object in storage. + type: string chartName: description: ChartName is the chart name of the release object in storage. @@ -3509,6 +3513,10 @@ spec: Provisional: when the calculation method of the Digest field is changed, this field will be used to distinguish between the old and new methods. type: string + appVersion: + description: AppVersion is the chart app version of the release + object in storage. + type: string chartName: description: ChartName is the chart name of the release object in storage. diff --git a/docs/api/v2/helm.md b/docs/api/v2/helm.md index ea6ea2335..075a53055 100644 --- a/docs/api/v2/helm.md +++ b/docs/api/v2/helm.md @@ -2243,48 +2243,48 @@ int -appVersion
+status
string -(Optional) -

Version is the version of the release object in storage.

+

Status is the current state of the release.

-status
+chartName
string -

Status is the current state of the release.

+

ChartName is the chart name of the release object in storage.

-chartName
+chartVersion
string -

ChartName is the chart name of the release object in storage.

+

ChartVersion is the chart version of the release object in +storage.

-chartVersion
+appVersion
string -

ChartVersion is the chart version of the release object in -storage.

+(Optional) +

AppVersion is the chart app version of the release object in storage.

diff --git a/internal/reconcile/release.go b/internal/reconcile/release.go index 6b87249bb..049eaf421 100644 --- a/internal/reconcile/release.go +++ b/internal/reconcile/release.go @@ -200,11 +200,13 @@ func eventMessageWithLog(msg string, log *action.LogBuffer) string { // addMeta is a function that adds metadata to an event map. type addMeta func(map[string]string) -// metaOCIDigestKey is the key for the OCI digest metadata. -const metaOCIDigestKey = "oci-digest" +const ( + // metaOCIDigestKey is the key for the chart OCI artifact digest. + metaOCIDigestKey = "oci-digest" -// metaAppVersionKey is the key for the app version found in chart metadata. -const metaAppVersionKey = "app-version" + // metaAppVersionKey is the key for the app version found in chart metadata. + metaAppVersionKey = "app-version" +) // eventMeta returns the event (annotation) metadata based on the given // parameters.