From d0900635cf221119938876307dbc2bd45f94cc23 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Fri, 3 May 2024 13:43:51 +0300 Subject: [PATCH] Update `HelmChart` API to v1 (GA) Bump source-controller to v1.3.0 Signed-off-by: Stefan Prodan --- api/go.mod | 2 +- api/go.sum | 4 +- config/default/kustomization.yaml | 4 +- go.mod | 10 +- go.sum | 31 +-- internal/controller/helmrelease_controller.go | 28 +-- .../helmrelease_controller_fuzz_test.go | 2 +- .../controller/helmrelease_controller_test.go | 217 +++++++++--------- internal/controller/suite_test.go | 4 +- internal/reconcile/helmchart_template.go | 3 +- internal/reconcile/helmchart_template_test.go | 5 +- internal/reconcile/suite_test.go | 4 +- main.go | 4 +- 13 files changed, 163 insertions(+), 155 deletions(-) diff --git a/api/go.mod b/api/go.mod index f3de27192..4c0222953 100644 --- a/api/go.mod +++ b/api/go.mod @@ -7,7 +7,7 @@ require ( github.com/fluxcd/pkg/apis/meta v1.5.0 k8s.io/apiextensions-apiserver v0.30.0 k8s.io/apimachinery v0.30.0 - sigs.k8s.io/controller-runtime v0.18.0 + sigs.k8s.io/controller-runtime v0.18.1 sigs.k8s.io/yaml v1.4.0 ) diff --git a/api/go.sum b/api/go.sum index b34417e9c..e02974535 100644 --- a/api/go.sum +++ b/api/go.sum @@ -101,8 +101,8 @@ k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/utils v0.0.0-20231127182322-b307cd553661 h1:FepOBzJ0GXm8t0su67ln2wAZjbQ6RxQGZDnzuLcrUTI= k8s.io/utils v0.0.0-20231127182322-b307cd553661/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.18.0 h1:Z7jKuX784TQSUL1TIyeuF7j8KXZ4RtSX0YgtjKcSTME= -sigs.k8s.io/controller-runtime v0.18.0/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw= +sigs.k8s.io/controller-runtime v0.18.1 h1:RpWbigmuiylbxOCLy0tGnq1cU1qWPwNIQzoJk+QeJx4= +sigs.k8s.io/controller-runtime v0.18.1/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index c24c6b40d..494304478 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -2,8 +2,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namespace: helm-system resources: -- https://github.com/fluxcd/source-controller/releases/download/v1.2.4/source-controller.crds.yaml -- https://github.com/fluxcd/source-controller/releases/download/v1.2.4/source-controller.deployment.yaml +- https://github.com/fluxcd/source-controller/releases/download/v1.3.0/source-controller.crds.yaml +- https://github.com/fluxcd/source-controller/releases/download/v1.3.0/source-controller.deployment.yaml - ../crd - ../rbac - ../manager diff --git a/go.mod b/go.mod index 0d070dc01..14f1063a8 100644 --- a/go.mod +++ b/go.mod @@ -22,15 +22,15 @@ require ( github.com/fluxcd/pkg/apis/event v0.9.0 github.com/fluxcd/pkg/apis/kustomize v1.5.0 github.com/fluxcd/pkg/apis/meta v1.5.0 - github.com/fluxcd/pkg/runtime v0.47.0 - github.com/fluxcd/pkg/ssa v0.39.0 + github.com/fluxcd/pkg/runtime v0.47.1 + github.com/fluxcd/pkg/ssa v0.39.1 github.com/fluxcd/pkg/testserver v0.7.0 - github.com/fluxcd/source-controller/api v1.2.5 + github.com/fluxcd/source-controller/api v1.3.0 github.com/go-logr/logr v1.4.1 github.com/google/go-cmp v0.6.0 github.com/hashicorp/go-retryablehttp v0.7.5 github.com/mitchellh/copystructure v1.2.0 - github.com/onsi/gomega v1.32.0 + github.com/onsi/gomega v1.33.1 github.com/opencontainers/go-digest v1.0.1-0.20231025023718-d50d2fec9c98 github.com/opencontainers/go-digest/blake3 v0.0.0-20231212064514-429d0316a3dd github.com/spf13/pflag v1.0.5 @@ -44,7 +44,7 @@ require ( k8s.io/client-go v0.30.0 k8s.io/kubectl v0.30.0 k8s.io/utils v0.0.0-20240310230437-4693a0247e57 - sigs.k8s.io/controller-runtime v0.18.0 + sigs.k8s.io/controller-runtime v0.18.1 sigs.k8s.io/kustomize/api v0.17.1 sigs.k8s.io/kustomize/kyaml v0.17.0 sigs.k8s.io/yaml v1.4.0 diff --git a/go.sum b/go.sum index 65b0fc90a..d2b65f9df 100644 --- a/go.sum +++ b/go.sum @@ -108,14 +108,14 @@ github.com/fluxcd/pkg/apis/kustomize v1.5.0 h1:ah4sfqccnio+/5Edz/tVz6LetFhiBoDzX github.com/fluxcd/pkg/apis/kustomize v1.5.0/go.mod h1:nEzhnhHafhWOUUV8VMFLojUOH+HHDEsL75y54mt/c30= github.com/fluxcd/pkg/apis/meta v1.5.0 h1:/G82d2Az5D9op3F+wJUpD8jw/eTV0suM6P7+cSURoUM= github.com/fluxcd/pkg/apis/meta v1.5.0/go.mod h1:Y3u7JomuuKtr5fvP1Iji2/50FdRe5GcBug2jawNVkdM= -github.com/fluxcd/pkg/runtime v0.47.0 h1:m3BEgwTYJslIF0lqhZMw6ZcKD6bD+4Ut+Xd/8X86SZA= -github.com/fluxcd/pkg/runtime v0.47.0/go.mod h1:UgHy8DTkU2MFHDe2q3b+OP4mBYTsopGhSzWb8rHJa9Q= -github.com/fluxcd/pkg/ssa v0.39.0 h1:MdsTjwmF7mxTuZRt1XcLp5SzDI0PcRDR8bnbGH4nvHo= -github.com/fluxcd/pkg/ssa v0.39.0/go.mod h1:bS/QGx2YjAiyzPl1CGb8w+6ETmoIhpeViTcEnTpv+t4= +github.com/fluxcd/pkg/runtime v0.47.1 h1:Q1tAFsp92uurWyoEe52AmMC4k+6DYTPBrUQDs+nz/9c= +github.com/fluxcd/pkg/runtime v0.47.1/go.mod h1:97a+PqpWMgQsoqh91uH3EQz+/DC7Uxc8xcu/rDHFC5c= +github.com/fluxcd/pkg/ssa v0.39.1 h1:xPYRKqgqB5p+5jgz2xBkXCE/7i1FIOa+nA3Wr7Gu2Ek= +github.com/fluxcd/pkg/ssa v0.39.1/go.mod h1:AkhMoFxipMf3WoO3lkXjj2nHNIz6sA5yQ50aBodtxnk= github.com/fluxcd/pkg/testserver v0.7.0 h1:kNVAn+3bAF2rfR9cT6SxzgEz2o84i+o7zKY3XRKTXmk= github.com/fluxcd/pkg/testserver v0.7.0/go.mod h1:Ih5IK3Y5G3+a6c77BTqFkdPDCY1Yj1A1W5cXQqkCs9s= -github.com/fluxcd/source-controller/api v1.2.5 h1:MgGrOfPh7Grhl40GUM9lEs+lmgTx3hLAwI0MVqaJkQ8= -github.com/fluxcd/source-controller/api v1.2.5/go.mod h1:j3QSHpIPBP5sjaGIkVtsgWCx8JcOmcsutRmdJmRMOZg= +github.com/fluxcd/source-controller/api v1.3.0 h1:Z5Lq0aJY87yg0cQDEuwGLKS60GhdErCHtsi546HUt10= +github.com/fluxcd/source-controller/api v1.3.0/go.mod h1:+tfd0vltjcVs/bbnq9AlYR9AAHSVfM/Z4v4TpQmdJf4= github.com/foxcpp/go-mockdns v1.0.0 h1:7jBqxd3WDWwi/6WhDvacvH1XsN3rOLXyHM1uhvIx6FI= github.com/foxcpp/go-mockdns v1.0.0/go.mod h1:lgRN6+KxQBawyIghpnl5CezHFGS9VLzvtVlwxvzXTQ4= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= @@ -146,7 +146,8 @@ github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfC github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gobuffalo/logger v1.0.6 h1:nnZNpxYo0zx+Aj9RfMPBm+x9zAU2OayFh/xrAWi34HU= github.com/gobuffalo/logger v1.0.6/go.mod h1:J31TBEHR1QLV2683OXTAItYIg8pv2JMHnF/quuAbMjs= github.com/gobuffalo/packd v1.0.1 h1:U2wXfRr4E9DH8IdsDLlRFwTZTK7hLfq9qT/QHXGVe/0= @@ -178,8 +179,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= +github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -306,10 +307,10 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8= -github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= -github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk= -github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg= +github.com/onsi/ginkgo/v2 v2.17.2 h1:7eMhcy3GimbsA3hEnVKdw/PQM9XN9krpKVXsZdph0/g= +github.com/onsi/ginkgo/v2 v2.17.2/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= +github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= +github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/opencontainers/go-digest v1.0.1-0.20231025023718-d50d2fec9c98 h1:H55sU3giNgBkIvmAo0vI/AAFwVTwfWsf6MN3+9H6U8o= github.com/opencontainers/go-digest v1.0.1-0.20231025023718-d50d2fec9c98/go.mod h1:RqnyioA3pIEZMkSbOIcrw32YSgETfn/VrLuEikEdPNU= github.com/opencontainers/go-digest/blake3 v0.0.0-20231212064514-429d0316a3dd h1:6eP3AE0nXQEGF7Q4lj27mNp1dLHF/+Ab2he8fYPgxwA= @@ -565,8 +566,8 @@ k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0g k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= oras.land/oras-go v1.2.4 h1:djpBY2/2Cs1PV87GSJlxv4voajVOMZxqqtq9AB8YNvY= oras.land/oras-go v1.2.4/go.mod h1:DYcGfb3YF1nKjcezfX2SNlDAeQFKSXmf+qrFmrh4324= -sigs.k8s.io/controller-runtime v0.18.0 h1:Z7jKuX784TQSUL1TIyeuF7j8KXZ4RtSX0YgtjKcSTME= -sigs.k8s.io/controller-runtime v0.18.0/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw= +sigs.k8s.io/controller-runtime v0.18.1 h1:RpWbigmuiylbxOCLy0tGnq1cU1qWPwNIQzoJk+QeJx4= +sigs.k8s.io/controller-runtime v0.18.1/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/kustomize/api v0.17.0 h1:AygX5EzZ+2NDxCWkeHy4IK2oftvl4odZZJmq1rK4HYU= diff --git a/internal/controller/helmrelease_controller.go b/internal/controller/helmrelease_controller.go index ba7c0fe85..6fda164a3 100644 --- a/internal/controller/helmrelease_controller.go +++ b/internal/controller/helmrelease_controller.go @@ -55,8 +55,8 @@ import ( "github.com/fluxcd/pkg/runtime/object" "github.com/fluxcd/pkg/runtime/patch" "github.com/fluxcd/pkg/runtime/predicates" - source "github.com/fluxcd/source-controller/api/v1" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" + sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2" v2 "github.com/fluxcd/helm-controller/api/v2beta2" intacl "github.com/fluxcd/helm-controller/internal/acl" @@ -139,7 +139,7 @@ func (r *HelmReleaseReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M builder.WithPredicates(intpredicates.SourceRevisionChangePredicate{}), ). Watches( - &sourcev1.OCIRepository{}, + &sourcev1beta2.OCIRepository{}, handler.EnqueueRequestsFromMapFunc(r.requestsForOCIRrepositoryChange), builder.WithPredicates(intpredicates.SourceRevisionChangePredicate{}), ). @@ -683,10 +683,10 @@ func (r *HelmReleaseReconciler) buildRESTClientGetter(ctx context.Context, obj * // using the chartRef in the spec, or by looking up the HelmChart // referenced in the status object. // It returns the source object or an error. -func (r *HelmReleaseReconciler) getSource(ctx context.Context, obj *v2.HelmRelease) (source.Source, error) { +func (r *HelmReleaseReconciler) getSource(ctx context.Context, obj *v2.HelmRelease) (sourcev1.Source, error) { var name, namespace string if obj.HasChartRef() { - if obj.Spec.ChartRef.Kind == sourcev1.OCIRepositoryKind { + if obj.Spec.ChartRef.Kind == sourcev1beta2.OCIRepositoryKind { return r.getSourceFromOCIRef(ctx, obj) } name, namespace = obj.Spec.ChartRef.Name, obj.Spec.ChartRef.Namespace @@ -710,18 +710,18 @@ func (r *HelmReleaseReconciler) getSource(ctx context.Context, obj *v2.HelmRelea return &hc, nil } -func (r *HelmReleaseReconciler) getSourceFromOCIRef(ctx context.Context, obj *v2.HelmRelease) (source.Source, error) { +func (r *HelmReleaseReconciler) getSourceFromOCIRef(ctx context.Context, obj *v2.HelmRelease) (sourcev1.Source, error) { name, namespace := obj.Spec.ChartRef.Name, obj.Spec.ChartRef.Namespace if namespace == "" { namespace = obj.GetNamespace() } ociRepoRef := types.NamespacedName{Namespace: namespace, Name: name} - if err := intacl.AllowsAccessTo(obj, sourcev1.OCIRepositoryKind, ociRepoRef); err != nil { + if err := intacl.AllowsAccessTo(obj, sourcev1beta2.OCIRepositoryKind, ociRepoRef); err != nil { return nil, err } - or := sourcev1.OCIRepository{} + or := sourcev1beta2.OCIRepository{} if err := r.Client.Get(ctx, ociRepoRef, &or); err != nil { return nil, err } @@ -779,7 +779,7 @@ func (r *HelmReleaseReconciler) requestsForHelmChartChange(ctx context.Context, } func (r *HelmReleaseReconciler) requestsForOCIRrepositoryChange(ctx context.Context, o client.Object) []reconcile.Request { - or, ok := o.(*sourcev1.OCIRepository) + or, ok := o.(*sourcev1beta2.OCIRepository) if !ok { err := fmt.Errorf("expected an OCIRepository, got %T", o) ctrl.LoggerFrom(ctx).Error(err, "failed to get requests for OCIRepository change") @@ -818,14 +818,14 @@ func (r *HelmReleaseReconciler) requestsForOCIRrepositoryChange(ctx context.Cont return reqs } -func isSourceReady(obj source.Source) (bool, string) { +func isSourceReady(obj sourcev1.Source) (bool, string) { if o, ok := obj.(conditions.Getter); ok { return isReady(o, obj.GetArtifact()) } - return false, fmt.Sprintf("unknown source type: %T", obj) + return false, fmt.Sprintf("unknown sourcev1 type: %T", obj) } -func isReady(obj conditions.Getter, artifact *source.Artifact) (bool, string) { +func isReady(obj conditions.Getter, artifact *sourcev1.Artifact) (bool, string) { observedGen, err := object.GetStatusObservedGeneration(obj) if err != nil { return false, err.Error() @@ -877,11 +877,11 @@ func getNamespacedName(obj *v2.HelmRelease) (types.NamespacedName, error) { return namespacedName, nil } -func mutateChartWithSourceRevision(chart *chart.Chart, source source.Source) (string, error) { +func mutateChartWithSourceRevision(chart *chart.Chart, source sourcev1.Source) (string, error) { // If the source is an OCIRepository, we can try to mutate the chart version // with the artifact revision. The revision is either a @ or // just a digest. - obj, ok := source.(*sourcev1.OCIRepository) + obj, ok := source.(*sourcev1beta2.OCIRepository) if !ok { // if not make sure to return an empty string to delete the digest of the // last attempted revision diff --git a/internal/controller/helmrelease_controller_fuzz_test.go b/internal/controller/helmrelease_controller_fuzz_test.go index 4c7fc203c..a66978c92 100644 --- a/internal/controller/helmrelease_controller_fuzz_test.go +++ b/internal/controller/helmrelease_controller_fuzz_test.go @@ -33,7 +33,7 @@ import ( "sigs.k8s.io/yaml" "github.com/fluxcd/pkg/runtime/patch" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" v2 "github.com/fluxcd/helm-controller/api/v2beta2" ) diff --git a/internal/controller/helmrelease_controller_test.go b/internal/controller/helmrelease_controller_test.go index 739b4032b..76fc285ca 100644 --- a/internal/controller/helmrelease_controller_test.go +++ b/internal/controller/helmrelease_controller_test.go @@ -24,14 +24,6 @@ import ( "testing" "time" - "github.com/fluxcd/pkg/apis/acl" - aclv1 "github.com/fluxcd/pkg/apis/acl" - "github.com/fluxcd/pkg/apis/meta" - "github.com/fluxcd/pkg/runtime/conditions" - feathelper "github.com/fluxcd/pkg/runtime/features" - "github.com/fluxcd/pkg/runtime/patch" - sourcev1 "github.com/fluxcd/source-controller/api/v1" - sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2" . "github.com/onsi/gomega" "github.com/opencontainers/go-digest" "helm.sh/helm/v3/pkg/chart" @@ -53,6 +45,15 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/yaml" + "github.com/fluxcd/pkg/apis/acl" + aclv1 "github.com/fluxcd/pkg/apis/acl" + "github.com/fluxcd/pkg/apis/meta" + "github.com/fluxcd/pkg/runtime/conditions" + feathelper "github.com/fluxcd/pkg/runtime/features" + "github.com/fluxcd/pkg/runtime/patch" + sourcev1 "github.com/fluxcd/source-controller/api/v1" + sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2" + v2 "github.com/fluxcd/helm-controller/api/v2beta2" intacl "github.com/fluxcd/helm-controller/internal/acl" "github.com/fluxcd/helm-controller/internal/action" @@ -185,17 +186,17 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) { t.Run("waits for HelmChart to have an Artifact", func(t *testing.T) { g := NewWithT(t) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ TypeMeta: metav1.TypeMeta{ - APIVersion: sourcev1b2.GroupVersion.String(), - Kind: sourcev1b2.HelmChartKind, + APIVersion: sourcev1.GroupVersion.String(), + Kind: sourcev1.HelmChartKind, }, ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 2, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 2, Artifact: nil, Conditions: []metav1.Condition{ @@ -241,17 +242,17 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) { t.Run("waits for HelmChart ObservedGeneration to equal Generation", func(t *testing.T) { g := NewWithT(t) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ TypeMeta: metav1.TypeMeta{ - APIVersion: sourcev1b2.GroupVersion.String(), - Kind: sourcev1b2.HelmChartKind, + APIVersion: sourcev1.GroupVersion.String(), + Kind: sourcev1.HelmChartKind, }, ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 2, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 1, Artifact: &sourcev1.Artifact{}, Conditions: []metav1.Condition{ @@ -297,16 +298,16 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) { t.Run("reports values composition failure", func(t *testing.T) { g := NewWithT(t) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 2, }, - Spec: sourcev1b2.HelmChartSpec{ + Spec: sourcev1.HelmChartSpec{ Interval: metav1.Duration{Duration: 1 * time.Second}, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 2, Artifact: &sourcev1.Artifact{}, Conditions: []metav1.Condition{ @@ -357,13 +358,13 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) { t.Run("reports Helm chart load failure", func(t *testing.T) { g := NewWithT(t) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 1, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 1, Artifact: &sourcev1.Artifact{ URL: testServer.URL() + "/does-not-exist", @@ -424,21 +425,21 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) { chartArtifact, err := testutil.SaveChartAsArtifact(chartMock, digest.SHA256, testServer.URL(), testServer.Root()) g.Expect(err).ToNot(HaveOccurred()) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "adopt-release", Namespace: ns.Name, Generation: 1, }, - Spec: sourcev1b2.HelmChartSpec{ + Spec: sourcev1.HelmChartSpec{ Chart: "testdata/test-helmrepo", Version: "0.1.0", - SourceRef: sourcev1b2.LocalHelmChartSourceReference{ - Kind: sourcev1b2.HelmRepositoryKind, + SourceRef: sourcev1.LocalHelmChartSourceReference{ + Kind: sourcev1.HelmRepositoryKind, Name: "reconcile-delete", }, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 1, Artifact: chartArtifact, Conditions: []metav1.Condition{ @@ -517,13 +518,13 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) { chartArtifact, err := testutil.SaveChartAsArtifact(chartMock, digest.SHA256, testServer.URL(), testServer.Root()) g.Expect(err).ToNot(HaveOccurred()) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 1, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 1, Artifact: chartArtifact, Conditions: []metav1.Condition{ @@ -589,13 +590,13 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) { chartArtifact, err := testutil.SaveChartAsArtifact(chartMock, digest.SHA256, testServer.URL(), testServer.Root()) g.Expect(err).ToNot(HaveOccurred()) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 1, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 1, Artifact: chartArtifact, Conditions: []metav1.Condition{ @@ -659,13 +660,13 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) { chartArtifact, err := testutil.SaveChartAsArtifact(chartMock, digest.SHA256, testServer.URL(), testServer.Root()) g.Expect(err).ToNot(HaveOccurred()) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 1, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 1, Artifact: chartArtifact, Conditions: []metav1.Condition{ @@ -739,21 +740,21 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) { chartArtifact, err := testutil.SaveChartAsArtifact(chartMock, digest.SHA256, testServer.URL(), testServer.Root()) g.Expect(err).ToNot(HaveOccurred()) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "error-recovery", Namespace: ns.Name, Generation: 1, }, - Spec: sourcev1b2.HelmChartSpec{ + Spec: sourcev1.HelmChartSpec{ Chart: "testdata/test-helmrepo", Version: "0.1.0", - SourceRef: sourcev1b2.LocalHelmChartSourceReference{ - Kind: sourcev1b2.HelmRepositoryKind, + SourceRef: sourcev1.LocalHelmChartSourceReference{ + Kind: sourcev1.HelmRepositoryKind, Name: "error-recovery", }, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 1, Artifact: chartArtifact, Conditions: []metav1.Condition{ @@ -857,7 +858,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T) }, Spec: v2.HelmReleaseSpec{ ChartRef: &v2.CrossNamespaceSourceReference{ - Kind: sourcev1b2.HelmChartKind, + Kind: sourcev1.HelmChartKind, Name: "chart", Namespace: "mock", }, @@ -902,7 +903,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T) }, Spec: v2.HelmReleaseSpec{ ChartRef: &v2.CrossNamespaceSourceReference{ - Kind: sourcev1b2.HelmChartKind, + Kind: sourcev1.HelmChartKind, Name: "chart", Namespace: "mock", }, @@ -937,7 +938,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T) }, Spec: v2.HelmReleaseSpec{ ChartRef: &v2.CrossNamespaceSourceReference{ - Kind: sourcev1b2.HelmChartKind, + Kind: sourcev1.HelmChartKind, Name: "chart", Namespace: "mock-other", }, @@ -967,17 +968,17 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T) t.Run("waits for ChartRef to have an Artifact", func(t *testing.T) { g := NewWithT(t) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ TypeMeta: metav1.TypeMeta{ - APIVersion: sourcev1b2.GroupVersion.String(), - Kind: sourcev1b2.HelmChartKind, + APIVersion: sourcev1.GroupVersion.String(), + Kind: sourcev1.HelmChartKind, }, ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 2, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 2, Conditions: []metav1.Condition{ { @@ -995,7 +996,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T) }, Spec: v2.HelmReleaseSpec{ ChartRef: &v2.CrossNamespaceSourceReference{ - Kind: sourcev1b2.HelmChartKind, + Kind: sourcev1.HelmChartKind, Name: "chart", Namespace: "mock", }, @@ -1024,16 +1025,16 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T) t.Run("reports Helm chart load failure", func(t *testing.T) { g := NewWithT(t) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 2, }, - Spec: sourcev1b2.HelmChartSpec{ + Spec: sourcev1.HelmChartSpec{ Interval: metav1.Duration{Duration: 1 * time.Second}, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 2, Artifact: &sourcev1.Artifact{ URL: testServer.URL() + "/does-not-exist", @@ -1054,7 +1055,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T) }, Spec: v2.HelmReleaseSpec{ ChartRef: &v2.CrossNamespaceSourceReference{ - Kind: sourcev1b2.HelmChartKind, + Kind: sourcev1.HelmChartKind, Name: "chart", Namespace: "mock", }, @@ -1083,13 +1084,13 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T) t.Run("report helmChart load failure when switching from existing HelmChat to chartRef", func(t *testing.T) { g := NewWithT(t) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 1, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 1, Artifact: &sourcev1.Artifact{}, Conditions: []metav1.Condition{ @@ -1101,16 +1102,16 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T) }, } - sharedChart := &sourcev1b2.HelmChart{ + sharedChart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "sharedChart", Namespace: "mock", Generation: 2, }, - Spec: sourcev1b2.HelmChartSpec{ + Spec: sourcev1.HelmChartSpec{ Interval: metav1.Duration{Duration: 1 * time.Second}, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 2, Artifact: &sourcev1.Artifact{ URL: testServer.URL() + "/does-not-exist", @@ -1131,7 +1132,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T) }, Spec: v2.HelmReleaseSpec{ ChartRef: &v2.CrossNamespaceSourceReference{ - Kind: sourcev1b2.HelmChartKind, + Kind: sourcev1.HelmChartKind, Name: "sharedChart", Namespace: "mock", }, @@ -1283,17 +1284,17 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin t.Run("waits for ChartRef to have an Artifact", func(t *testing.T) { g := NewWithT(t) - ocirepo := &sourcev1b2.OCIRepository{ + ocirepo := &sourcev1beta2.OCIRepository{ TypeMeta: metav1.TypeMeta{ - APIVersion: sourcev1b2.GroupVersion.String(), - Kind: sourcev1b2.OCIRepositoryKind, + APIVersion: sourcev1beta2.GroupVersion.String(), + Kind: sourcev1beta2.OCIRepositoryKind, }, ObjectMeta: metav1.ObjectMeta{ Name: "ocirepo", Namespace: "mock", Generation: 2, }, - Status: sourcev1b2.OCIRepositoryStatus{ + Status: sourcev1beta2.OCIRepositoryStatus{ ObservedGeneration: 2, Conditions: []metav1.Condition{ { @@ -1340,16 +1341,16 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin t.Run("reports values composition failure", func(t *testing.T) { g := NewWithT(t) - ocirepo := &sourcev1b2.OCIRepository{ + ocirepo := &sourcev1beta2.OCIRepository{ ObjectMeta: metav1.ObjectMeta{ Name: "ocirepo", Namespace: "mock", Generation: 2, }, - Spec: sourcev1b2.OCIRepositorySpec{ + Spec: sourcev1beta2.OCIRepositorySpec{ Interval: metav1.Duration{Duration: 1 * time.Second}, }, - Status: sourcev1b2.OCIRepositoryStatus{ + Status: sourcev1beta2.OCIRepositoryStatus{ ObservedGeneration: 2, Artifact: &sourcev1.Artifact{}, Conditions: []metav1.Condition{ @@ -1402,16 +1403,16 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin t.Run("reports Helm chart load failure", func(t *testing.T) { g := NewWithT(t) - ocirepo := &sourcev1b2.OCIRepository{ + ocirepo := &sourcev1beta2.OCIRepository{ ObjectMeta: metav1.ObjectMeta{ Name: "ocirepo", Namespace: "mock", Generation: 2, }, - Spec: sourcev1b2.OCIRepositorySpec{ + Spec: sourcev1beta2.OCIRepositorySpec{ Interval: metav1.Duration{Duration: 1 * time.Second}, }, - Status: sourcev1b2.OCIRepositoryStatus{ + Status: sourcev1beta2.OCIRepositoryStatus{ ObservedGeneration: 2, Artifact: &sourcev1.Artifact{ URL: testServer.URL() + "/does-not-exist", @@ -1461,13 +1462,13 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin t.Run("report helmChart load failure when switching from existing HelmChat to chartRef", func(t *testing.T) { g := NewWithT(t) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: "mock", Generation: 1, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 1, Artifact: &sourcev1.Artifact{}, Conditions: []metav1.Condition{ @@ -1479,16 +1480,16 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin }, } - ocirepo := &sourcev1b2.OCIRepository{ + ocirepo := &sourcev1beta2.OCIRepository{ ObjectMeta: metav1.ObjectMeta{ Name: "ocirepo", Namespace: "mock", Generation: 2, }, - Spec: sourcev1b2.OCIRepositorySpec{ + Spec: sourcev1beta2.OCIRepositorySpec{ Interval: metav1.Duration{Duration: 1 * time.Second}, }, - Status: sourcev1b2.OCIRepositoryStatus{ + Status: sourcev1beta2.OCIRepositoryStatus{ ObservedGeneration: 2, Artifact: &sourcev1.Artifact{ URL: testServer.URL() + "/does-not-exist", @@ -1548,16 +1549,16 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin g.Expect(err).ToNot(HaveOccurred()) chartArtifact.Revision += "@" + chartArtifact.Digest - ocirepo := &sourcev1b2.OCIRepository{ + ocirepo := &sourcev1beta2.OCIRepository{ ObjectMeta: metav1.ObjectMeta{ Name: "ocirepo", Namespace: "mock", Generation: 1, }, - Spec: sourcev1b2.OCIRepositorySpec{ + Spec: sourcev1beta2.OCIRepositorySpec{ Interval: metav1.Duration{Duration: 1 * time.Second}, }, - Status: sourcev1b2.OCIRepositoryStatus{ + Status: sourcev1beta2.OCIRepositoryStatus{ ObservedGeneration: 1, Artifact: chartArtifact, Conditions: []metav1.Condition{ @@ -1639,21 +1640,21 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin }) // hc is the HelmChart object created by the HelmRelease object. - hc := &sourcev1b2.HelmChart{ + hc := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "chart", Namespace: ns.Name, Generation: 1, }, - Spec: sourcev1b2.HelmChartSpec{ + Spec: sourcev1.HelmChartSpec{ Chart: "testdata/test-helmrepo", Version: "0.1.0", - SourceRef: sourcev1b2.LocalHelmChartSourceReference{ - Kind: sourcev1b2.HelmRepositoryKind, + SourceRef: sourcev1.LocalHelmChartSourceReference{ + Kind: sourcev1.HelmRepositoryKind, Name: "test-helmrepo", }, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 1, Artifact: chartArtifact, Conditions: []metav1.Condition{ @@ -1666,17 +1667,17 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin } // ocirepo is the chartRef object to switch to. - ocirepo := &sourcev1b2.OCIRepository{ + ocirepo := &sourcev1beta2.OCIRepository{ ObjectMeta: metav1.ObjectMeta{ Name: "ocirepo", Namespace: ns.Name, Generation: 1, }, - Spec: sourcev1b2.OCIRepositorySpec{ + Spec: sourcev1beta2.OCIRepositorySpec{ URL: "oci://test-example.com", Interval: metav1.Duration{Duration: 1 * time.Second}, }, - Status: sourcev1b2.OCIRepositoryStatus{ + Status: sourcev1beta2.OCIRepositoryStatus{ ObservedGeneration: 1, Artifact: ociArtifact, Conditions: []metav1.Condition{ @@ -1773,16 +1774,16 @@ func TestHelmReleaseReconciler_reconcileDelete(t *testing.T) { }) // Create HelmChart mock. - hc := &sourcev1b2.HelmChart{ + hc := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Name: "reconcile-delete", Namespace: ns.Name, }, - Spec: sourcev1b2.HelmChartSpec{ + Spec: sourcev1.HelmChartSpec{ Chart: "testdata/test-helmrepo", Version: "0.1.0", - SourceRef: sourcev1b2.LocalHelmChartSourceReference{ - Kind: sourcev1b2.HelmRepositoryKind, + SourceRef: sourcev1.LocalHelmChartSourceReference{ + Kind: sourcev1.HelmRepositoryKind, Name: "reconcile-delete", }, }, @@ -1847,7 +1848,7 @@ func TestHelmReleaseReconciler_reconcileDelete(t *testing.T) { err = testEnv.Get(context.TODO(), client.ObjectKey{ Namespace: hc.Namespace, Name: hc.Name, - }, &sourcev1b2.HelmChart{}) + }, &sourcev1.HelmChart{}) g.Expect(err).To(HaveOccurred()) g.Expect(apierrors.IsNotFound(err)).To(BeTrue()) }).Should(Succeed()) @@ -2827,7 +2828,7 @@ users: func TestHelmReleaseReconciler_getHelmChart(t *testing.T) { g := NewWithT(t) - chart := &sourcev1b2.HelmChart{ + chart := &sourcev1.HelmChart{ ObjectMeta: metav1.ObjectMeta{ Namespace: "some-namespace", Name: "some-chart-name", @@ -2837,7 +2838,7 @@ func TestHelmReleaseReconciler_getHelmChart(t *testing.T) { tests := []struct { name string rel *v2.HelmRelease - chart *sourcev1b2.HelmChart + chart *sourcev1.HelmChart expectChart bool wantErr bool disallowCrossNS bool @@ -2914,7 +2915,7 @@ func TestHelmReleaseReconciler_getHelmChart(t *testing.T) { return } g.Expect(err).ToNot(HaveOccurred()) - hc, ok := got.(*sourcev1b2.HelmChart) + hc, ok := got.(*sourcev1.HelmChart) g.Expect(ok).To(BeTrue()) expect := g.Expect(hc.ObjectMeta) if tt.expectChart { @@ -3203,17 +3204,17 @@ func TestValuesReferenceValidation(t *testing.T) { } func Test_isHelmChartReady(t *testing.T) { - mock := &sourcev1b2.HelmChart{ + mock := &sourcev1.HelmChart{ TypeMeta: metav1.TypeMeta{ Kind: "HelmChart", - APIVersion: sourcev1b2.GroupVersion.String(), + APIVersion: sourcev1.GroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ Name: "mock", Namespace: "default", Generation: 2, }, - Status: sourcev1b2.HelmChartStatus{ + Status: sourcev1.HelmChartStatus{ ObservedGeneration: 2, Conditions: []metav1.Condition{ { @@ -3227,7 +3228,7 @@ func Test_isHelmChartReady(t *testing.T) { tests := []struct { name string - obj *sourcev1b2.HelmChart + obj *sourcev1.HelmChart want bool wantReason string }{ @@ -3238,7 +3239,7 @@ func Test_isHelmChartReady(t *testing.T) { }, { name: "chart generation differs from observed generation while Ready=True", - obj: func() *sourcev1b2.HelmChart { + obj: func() *sourcev1.HelmChart { m := mock.DeepCopy() m.Generation = 3 return m @@ -3248,7 +3249,7 @@ func Test_isHelmChartReady(t *testing.T) { }, { name: "chart generation differs from observed generation while Ready=False", - obj: func() *sourcev1b2.HelmChart { + obj: func() *sourcev1.HelmChart { m := mock.DeepCopy() m.Generation = 3 conditions.MarkFalse(m, meta.ReadyCondition, "Reason", "some reason") @@ -3259,7 +3260,7 @@ func Test_isHelmChartReady(t *testing.T) { }, { name: "chart has Stalled=True", - obj: func() *sourcev1b2.HelmChart { + obj: func() *sourcev1.HelmChart { m := mock.DeepCopy() conditions.MarkFalse(m, meta.ReadyCondition, "Reason", "some reason") conditions.MarkStalled(m, "Reason", "some stalled reason") @@ -3270,7 +3271,7 @@ func Test_isHelmChartReady(t *testing.T) { }, { name: "chart does not have an Artifact", - obj: func() *sourcev1b2.HelmChart { + obj: func() *sourcev1.HelmChart { m := mock.DeepCopy() m.Status.Artifact = nil return m @@ -3293,17 +3294,17 @@ func Test_isHelmChartReady(t *testing.T) { } func Test_isOCIRepositoryReady(t *testing.T) { - mock := &sourcev1b2.OCIRepository{ + mock := &sourcev1beta2.OCIRepository{ TypeMeta: metav1.TypeMeta{ - Kind: "OCIRepository", - APIVersion: sourcev1b2.GroupVersion.String(), + Kind: sourcev1beta2.OCIRepositoryKind, + APIVersion: sourcev1beta2.GroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ Name: "mock", Namespace: "default", Generation: 2, }, - Status: sourcev1b2.OCIRepositoryStatus{ + Status: sourcev1beta2.OCIRepositoryStatus{ ObservedGeneration: 2, Conditions: []metav1.Condition{ { @@ -3317,7 +3318,7 @@ func Test_isOCIRepositoryReady(t *testing.T) { tests := []struct { name string - obj *sourcev1b2.OCIRepository + obj *sourcev1beta2.OCIRepository want bool wantReason string }{ @@ -3328,7 +3329,7 @@ func Test_isOCIRepositoryReady(t *testing.T) { }, { name: "OCIRepository generation differs from observed generation while Ready=True", - obj: func() *sourcev1b2.OCIRepository { + obj: func() *sourcev1beta2.OCIRepository { m := mock.DeepCopy() m.Generation = 3 return m @@ -3338,7 +3339,7 @@ func Test_isOCIRepositoryReady(t *testing.T) { }, { name: "OCIRepository generation differs from observed generation while Ready=False", - obj: func() *sourcev1b2.OCIRepository { + obj: func() *sourcev1beta2.OCIRepository { m := mock.DeepCopy() m.Generation = 3 conditions.MarkFalse(m, meta.ReadyCondition, "Reason", "some reason") @@ -3349,7 +3350,7 @@ func Test_isOCIRepositoryReady(t *testing.T) { }, { name: "OCIRepository has Stalled=True", - obj: func() *sourcev1b2.OCIRepository { + obj: func() *sourcev1beta2.OCIRepository { m := mock.DeepCopy() conditions.MarkFalse(m, meta.ReadyCondition, "Reason", "some reason") conditions.MarkStalled(m, "Reason", "some stalled reason") @@ -3360,7 +3361,7 @@ func Test_isOCIRepositoryReady(t *testing.T) { }, { name: "OCIRepository does not have an Artifact", - obj: func() *sourcev1b2.OCIRepository { + obj: func() *sourcev1beta2.OCIRepository { m := mock.DeepCopy() m.Status.Artifact = nil return m @@ -3430,8 +3431,8 @@ func Test_TryMutateChartWithSourceRevision(t *testing.T) { }, } - s := &sourcev1b2.OCIRepository{ - Status: sourcev1b2.OCIRepositoryStatus{ + s := &sourcev1beta2.OCIRepository{ + Status: sourcev1beta2.OCIRepositoryStatus{ Artifact: &sourcev1.Artifact{ Revision: tt.revision, }, diff --git a/internal/controller/suite_test.go b/internal/controller/suite_test.go index 427007e3d..eeb9e26ba 100644 --- a/internal/controller/suite_test.go +++ b/internal/controller/suite_test.go @@ -31,7 +31,8 @@ import ( "github.com/fluxcd/pkg/runtime/testenv" "github.com/fluxcd/pkg/testserver" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" + sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2" v2 "github.com/fluxcd/helm-controller/api/v2beta2" // +kubebuilder:scaffold:imports @@ -49,6 +50,7 @@ func NewTestScheme() *runtime.Scheme { utilruntime.Must(corev1.AddToScheme(s)) utilruntime.Must(apiextensionsv1.AddToScheme(s)) utilruntime.Must(sourcev1.AddToScheme(s)) + utilruntime.Must(sourcev1beta2.AddToScheme(s)) utilruntime.Must(v2.AddToScheme(s)) return s } diff --git a/internal/reconcile/helmchart_template.go b/internal/reconcile/helmchart_template.go index 4769c21dd..2dd82e2b2 100644 --- a/internal/reconcile/helmchart_template.go +++ b/internal/reconcile/helmchart_template.go @@ -32,7 +32,7 @@ import ( eventv1 "github.com/fluxcd/pkg/apis/event/v1beta1" "github.com/fluxcd/pkg/ssa" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" v2 "github.com/fluxcd/helm-controller/api/v2beta2" "github.com/fluxcd/helm-controller/internal/acl" @@ -229,7 +229,6 @@ func buildHelmChartFromTemplate(obj *v2.HelmRelease) *sourcev1.HelmChart { Interval: template.GetInterval(obj.Spec.Interval), ReconcileStrategy: template.Spec.ReconcileStrategy, ValuesFiles: template.Spec.ValuesFiles, - ValuesFile: template.Spec.ValuesFile, }, } if verifyTpl := template.Spec.Verify; verifyTpl != nil { diff --git a/internal/reconcile/helmchart_template_test.go b/internal/reconcile/helmchart_template_test.go index 5265d5778..8cee2bcc7 100644 --- a/internal/reconcile/helmchart_template_test.go +++ b/internal/reconcile/helmchart_template_test.go @@ -31,7 +31,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "github.com/fluxcd/pkg/apis/meta" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" + sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2" v2 "github.com/fluxcd/helm-controller/api/v2beta2" "github.com/fluxcd/helm-controller/internal/acl" @@ -484,7 +485,7 @@ func TestHelmChartTemplate_Reconcile(t *testing.T) { Spec: v2.HelmReleaseSpec{ Interval: metav1.Duration{Duration: 1 * time.Hour}, ChartRef: &v2.CrossNamespaceSourceReference{ - Kind: sourcev1.OCIRepositoryKind, + Kind: sourcev1beta2.OCIRepositoryKind, Name: "oci-repository", }, }, diff --git a/internal/reconcile/suite_test.go b/internal/reconcile/suite_test.go index ab059265c..caa7fdee7 100644 --- a/internal/reconcile/suite_test.go +++ b/internal/reconcile/suite_test.go @@ -39,7 +39,8 @@ import ( "github.com/fluxcd/pkg/runtime/testenv" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" + sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2" v2 "github.com/fluxcd/helm-controller/api/v2beta2" ) @@ -56,6 +57,7 @@ func NewTestScheme() *runtime.Scheme { utilruntime.Must(corev1.AddToScheme(s)) utilruntime.Must(apiextensionsv1.AddToScheme(s)) utilruntime.Must(sourcev1.AddToScheme(s)) + utilruntime.Must(sourcev1beta2.AddToScheme(s)) utilruntime.Must(v2.AddToScheme(s)) return s } diff --git a/main.go b/main.go index 9d87b6edf..43ceec888 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,8 @@ import ( "github.com/fluxcd/pkg/runtime/metrics" "github.com/fluxcd/pkg/runtime/pprof" "github.com/fluxcd/pkg/runtime/probes" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" + sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2" v2 "github.com/fluxcd/helm-controller/api/v2beta2" intdigest "github.com/fluxcd/helm-controller/internal/digest" @@ -71,6 +72,7 @@ func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(sourcev1.AddToScheme(scheme)) + utilruntime.Must(sourcev1beta2.AddToScheme(scheme)) utilruntime.Must(v2.AddToScheme(scheme)) // +kubebuilder:scaffold:scheme }