From 1aaa48fa097f4abc04ba2d25e9004d6f409d2169 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Mon, 6 May 2024 12:28:34 +0300 Subject: [PATCH] Update Helm Source APIs to v1 (GA) Signed-off-by: Stefan Prodan --- cmd/flux/create_source_helm.go | 2 +- cmd/flux/create_source_oci.go | 15 ++++++------ cmd/flux/export_source_helm.go | 2 +- cmd/flux/get_source_all.go | 4 ++-- cmd/flux/get_source_chart.go | 2 +- cmd/flux/get_source_helm.go | 2 +- cmd/flux/reconcile_helmrelease.go | 4 ++-- cmd/flux/reconcile_source_chart.go | 8 +++---- cmd/flux/reconcile_source_helm.go | 2 +- cmd/flux/resume_source_chart.go | 2 +- cmd/flux/resume_source_helm.go | 2 +- cmd/flux/source.go | 24 +++++++++---------- cmd/flux/suspend_source_chart.go | 2 +- cmd/flux/suspend_source_helm.go | 2 +- .../testdata/create_source_helm/https.golden | 2 +- .../create_source_helm/oci-with-secret.golden | 2 +- .../testdata/create_source_helm/oci.golden | 2 +- cmd/flux/testdata/export/helm-repo.yaml | 2 +- 18 files changed, 41 insertions(+), 40 deletions(-) diff --git a/cmd/flux/create_source_helm.go b/cmd/flux/create_source_helm.go index 522e980f..b4f61309 100644 --- a/cmd/flux/create_source_helm.go +++ b/cmd/flux/create_source_helm.go @@ -32,7 +32,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" "github.com/fluxcd/flux2/v2/internal/utils" "github.com/fluxcd/flux2/v2/pkg/manifestgen/sourcesecret" diff --git a/cmd/flux/create_source_oci.go b/cmd/flux/create_source_oci.go index cf58dcf8..4713334a 100644 --- a/cmd/flux/create_source_oci.go +++ b/cmd/flux/create_source_oci.go @@ -30,7 +30,8 @@ import ( "github.com/fluxcd/pkg/apis/meta" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" + sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2" "github.com/fluxcd/flux2/v2/internal/flags" "github.com/fluxcd/flux2/v2/internal/utils" @@ -79,7 +80,7 @@ var sourceOCIRepositoryArgs = newSourceOCIFlags() func newSourceOCIFlags() sourceOCIRepositoryFlags { return sourceOCIRepositoryFlags{ - provider: flags.SourceOCIProvider(sourcev1.GenericOCIProvider), + provider: flags.SourceOCIProvider(sourcev1b2.GenericOCIProvider), } } @@ -124,20 +125,20 @@ func createSourceOCIRepositoryCmdRun(cmd *cobra.Command, args []string) error { ignorePaths = &ignorePathsStr } - repository := &sourcev1.OCIRepository{ + repository := &sourcev1b2.OCIRepository{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: *kubeconfigArgs.Namespace, Labels: sourceLabels, }, - Spec: sourcev1.OCIRepositorySpec{ + Spec: sourcev1b2.OCIRepositorySpec{ Provider: sourceOCIRepositoryArgs.provider.String(), URL: sourceOCIRepositoryArgs.url, Insecure: sourceOCIRepositoryArgs.insecure, Interval: metav1.Duration{ Duration: createArgs.interval, }, - Reference: &sourcev1.OCIRepositoryRef{}, + Reference: &sourcev1b2.OCIRepositoryRef{}, Ignore: ignorePaths, }, } @@ -228,13 +229,13 @@ func createSourceOCIRepositoryCmdRun(cmd *cobra.Command, args []string) error { } func upsertOCIRepository(ctx context.Context, kubeClient client.Client, - ociRepository *sourcev1.OCIRepository) (types.NamespacedName, error) { + ociRepository *sourcev1b2.OCIRepository) (types.NamespacedName, error) { namespacedName := types.NamespacedName{ Namespace: ociRepository.GetNamespace(), Name: ociRepository.GetName(), } - var existing sourcev1.OCIRepository + var existing sourcev1b2.OCIRepository err := kubeClient.Get(ctx, namespacedName, &existing) if err != nil { if errors.IsNotFound(err) { diff --git a/cmd/flux/export_source_helm.go b/cmd/flux/export_source_helm.go index f52e5010..f15d7b54 100644 --- a/cmd/flux/export_source_helm.go +++ b/cmd/flux/export_source_helm.go @@ -21,7 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" ) var exportSourceHelmCmd = &cobra.Command{ diff --git a/cmd/flux/get_source_all.go b/cmd/flux/get_source_all.go index c6736c74..5dfb9f97 100644 --- a/cmd/flux/get_source_all.go +++ b/cmd/flux/get_source_all.go @@ -54,11 +54,11 @@ var getSourceAllCmd = &cobra.Command{ }, { apiType: helmRepositoryType, - list: &helmRepositoryListAdapter{&sourcev1b2.HelmRepositoryList{}}, + list: &helmRepositoryListAdapter{&sourcev1.HelmRepositoryList{}}, }, { apiType: helmChartType, - list: &helmChartListAdapter{&sourcev1b2.HelmChartList{}}, + list: &helmChartListAdapter{&sourcev1.HelmChartList{}}, }, } diff --git a/cmd/flux/get_source_chart.go b/cmd/flux/get_source_chart.go index b82bdd78..c4a455ef 100644 --- a/cmd/flux/get_source_chart.go +++ b/cmd/flux/get_source_chart.go @@ -25,7 +25,7 @@ import ( "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" "github.com/fluxcd/flux2/v2/internal/utils" ) diff --git a/cmd/flux/get_source_helm.go b/cmd/flux/get_source_helm.go index ec131714..913276be 100644 --- a/cmd/flux/get_source_helm.go +++ b/cmd/flux/get_source_helm.go @@ -26,7 +26,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" "github.com/fluxcd/flux2/v2/internal/utils" ) diff --git a/cmd/flux/reconcile_helmrelease.go b/cmd/flux/reconcile_helmrelease.go index 1a1a5769..7d4449e9 100644 --- a/cmd/flux/reconcile_helmrelease.go +++ b/cmd/flux/reconcile_helmrelease.go @@ -19,11 +19,11 @@ package main import ( "fmt" + sourcev1 "github.com/fluxcd/source-controller/api/v1" "github.com/spf13/cobra" "k8s.io/apimachinery/pkg/types" helmv2 "github.com/fluxcd/helm-controller/api/v2beta2" - sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2" ) var reconcileHrCmd = &cobra.Command{ @@ -70,7 +70,7 @@ func (obj helmReleaseAdapter) reconcileSource() bool { func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName) { cmd := reconcileWithSourceCommand{ apiType: helmChartType, - object: helmChartAdapter{&sourcev1b2.HelmChart{}}, + object: helmChartAdapter{&sourcev1.HelmChart{}}, force: true, } diff --git a/cmd/flux/reconcile_source_chart.go b/cmd/flux/reconcile_source_chart.go index ead4fa76..7db42087 100644 --- a/cmd/flux/reconcile_source_chart.go +++ b/cmd/flux/reconcile_source_chart.go @@ -33,10 +33,10 @@ var reconcileSourceHelmChartCmd = &cobra.Command{ # Trigger a reconciliation of the HelmCharts's source and apply changes flux reconcile helmchart podinfo --with-source`, - ValidArgsFunction: resourceNamesCompletionFunc(sourcev1b2.GroupVersion.WithKind(sourcev1b2.HelmChartKind)), + ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1b2.HelmChartKind)), RunE: reconcileWithSourceCommand{ apiType: helmChartType, - object: helmChartAdapter{&sourcev1b2.HelmChart{}}, + object: helmChartAdapter{&sourcev1.HelmChart{}}, }.run, } @@ -62,10 +62,10 @@ func (obj helmChartAdapter) reconcileSource() bool { func (obj helmChartAdapter) getSource() (reconcileSource, types.NamespacedName) { var cmd reconcileCommand switch obj.Spec.SourceRef.Kind { - case sourcev1b2.HelmRepositoryKind: + case sourcev1.HelmRepositoryKind: cmd = reconcileCommand{ apiType: helmRepositoryType, - object: helmRepositoryAdapter{&sourcev1b2.HelmRepository{}}, + object: helmRepositoryAdapter{&sourcev1.HelmRepository{}}, } case sourcev1.GitRepositoryKind: cmd = reconcileCommand{ diff --git a/cmd/flux/reconcile_source_helm.go b/cmd/flux/reconcile_source_helm.go index a081fd0e..a9b89d3d 100644 --- a/cmd/flux/reconcile_source_helm.go +++ b/cmd/flux/reconcile_source_helm.go @@ -23,7 +23,7 @@ import ( "github.com/fluxcd/pkg/apis/meta" "github.com/fluxcd/pkg/runtime/conditions" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" ) var reconcileSourceHelmCmd = &cobra.Command{ diff --git a/cmd/flux/resume_source_chart.go b/cmd/flux/resume_source_chart.go index 6322f06f..9e7ec759 100644 --- a/cmd/flux/resume_source_chart.go +++ b/cmd/flux/resume_source_chart.go @@ -21,7 +21,7 @@ import ( "github.com/spf13/cobra" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" ) var resumeSourceHelmChartCmd = &cobra.Command{ diff --git a/cmd/flux/resume_source_helm.go b/cmd/flux/resume_source_helm.go index 0ac641eb..b4cb1316 100644 --- a/cmd/flux/resume_source_helm.go +++ b/cmd/flux/resume_source_helm.go @@ -19,7 +19,7 @@ package main import ( "github.com/spf13/cobra" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" ) var resumeSourceHelmCmd = &cobra.Command{ diff --git a/cmd/flux/source.go b/cmd/flux/source.go index 7dc96fdf..64f755be 100644 --- a/cmd/flux/source.go +++ b/cmd/flux/source.go @@ -95,16 +95,16 @@ func (a bucketListAdapter) len() int { return len(a.BucketList.Items) } -// sourcev1b2.HelmChart +// sourcev1.HelmChart var helmChartType = apiType{ - kind: sourcev1b2.HelmChartKind, + kind: sourcev1.HelmChartKind, humanKind: "source chart", - groupVersion: sourcev1b2.GroupVersion, + groupVersion: sourcev1.GroupVersion, } type helmChartAdapter struct { - *sourcev1b2.HelmChart + *sourcev1.HelmChart } func (a helmChartAdapter) asClientObject() client.Object { @@ -115,10 +115,10 @@ func (a helmChartAdapter) deepCopyClientObject() client.Object { return a.HelmChart.DeepCopy() } -// sourcev1b2.HelmChartList +// sourcev1.HelmChartList type helmChartListAdapter struct { - *sourcev1b2.HelmChartList + *sourcev1.HelmChartList } func (a helmChartListAdapter) asClientList() client.ObjectList { @@ -163,16 +163,16 @@ func (a gitRepositoryListAdapter) len() int { return len(a.GitRepositoryList.Items) } -// sourcev1b2.HelmRepository +// sourcev1.HelmRepository var helmRepositoryType = apiType{ - kind: sourcev1b2.HelmRepositoryKind, + kind: sourcev1.HelmRepositoryKind, humanKind: "source helm", - groupVersion: sourcev1b2.GroupVersion, + groupVersion: sourcev1.GroupVersion, } type helmRepositoryAdapter struct { - *sourcev1b2.HelmRepository + *sourcev1.HelmRepository } func (a helmRepositoryAdapter) asClientObject() client.Object { @@ -183,10 +183,10 @@ func (a helmRepositoryAdapter) deepCopyClientObject() client.Object { return a.HelmRepository.DeepCopy() } -// sourcev1b2.HelmRepositoryList +// sourcev1.HelmRepositoryList type helmRepositoryListAdapter struct { - *sourcev1b2.HelmRepositoryList + *sourcev1.HelmRepositoryList } func (a helmRepositoryListAdapter) asClientList() client.ObjectList { diff --git a/cmd/flux/suspend_source_chart.go b/cmd/flux/suspend_source_chart.go index e91327e8..6da1d8c0 100644 --- a/cmd/flux/suspend_source_chart.go +++ b/cmd/flux/suspend_source_chart.go @@ -19,7 +19,7 @@ package main import ( "github.com/spf13/cobra" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" ) var suspendSourceHelmChartCmd = &cobra.Command{ diff --git a/cmd/flux/suspend_source_helm.go b/cmd/flux/suspend_source_helm.go index 22598c64..a59343bd 100644 --- a/cmd/flux/suspend_source_helm.go +++ b/cmd/flux/suspend_source_helm.go @@ -19,7 +19,7 @@ package main import ( "github.com/spf13/cobra" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" + sourcev1 "github.com/fluxcd/source-controller/api/v1" ) var suspendSourceHelmCmd = &cobra.Command{ diff --git a/cmd/flux/testdata/create_source_helm/https.golden b/cmd/flux/testdata/create_source_helm/https.golden index 87235245..02da00a5 100644 --- a/cmd/flux/testdata/create_source_helm/https.golden +++ b/cmd/flux/testdata/create_source_helm/https.golden @@ -1,5 +1,5 @@ --- -apiVersion: source.toolkit.fluxcd.io/v1beta2 +apiVersion: source.toolkit.fluxcd.io/v1 kind: HelmRepository metadata: name: podinfo diff --git a/cmd/flux/testdata/create_source_helm/oci-with-secret.golden b/cmd/flux/testdata/create_source_helm/oci-with-secret.golden index 760a265c..d01f6f72 100644 --- a/cmd/flux/testdata/create_source_helm/oci-with-secret.golden +++ b/cmd/flux/testdata/create_source_helm/oci-with-secret.golden @@ -1,5 +1,5 @@ --- -apiVersion: source.toolkit.fluxcd.io/v1beta2 +apiVersion: source.toolkit.fluxcd.io/v1 kind: HelmRepository metadata: name: podinfo diff --git a/cmd/flux/testdata/create_source_helm/oci.golden b/cmd/flux/testdata/create_source_helm/oci.golden index f6049e99..92f09558 100644 --- a/cmd/flux/testdata/create_source_helm/oci.golden +++ b/cmd/flux/testdata/create_source_helm/oci.golden @@ -1,5 +1,5 @@ --- -apiVersion: source.toolkit.fluxcd.io/v1beta2 +apiVersion: source.toolkit.fluxcd.io/v1 kind: HelmRepository metadata: name: podinfo diff --git a/cmd/flux/testdata/export/helm-repo.yaml b/cmd/flux/testdata/export/helm-repo.yaml index c5366e0b..685b9079 100644 --- a/cmd/flux/testdata/export/helm-repo.yaml +++ b/cmd/flux/testdata/export/helm-repo.yaml @@ -1,5 +1,5 @@ --- -apiVersion: source.toolkit.fluxcd.io/v1beta2 +apiVersion: source.toolkit.fluxcd.io/v1 kind: HelmRepository metadata: name: flux-system