Update Helm Source APIs to v1 (GA)

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
pull/4759/head
Stefan Prodan 8 months ago
parent 89038b7300
commit 1aaa48fa09
No known key found for this signature in database
GPG Key ID: 3299AEB0E4085BAF

@ -32,7 +32,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml" "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/internal/utils"
"github.com/fluxcd/flux2/v2/pkg/manifestgen/sourcesecret" "github.com/fluxcd/flux2/v2/pkg/manifestgen/sourcesecret"

@ -30,7 +30,8 @@ import (
"github.com/fluxcd/pkg/apis/meta" "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/flags"
"github.com/fluxcd/flux2/v2/internal/utils" "github.com/fluxcd/flux2/v2/internal/utils"
@ -79,7 +80,7 @@ var sourceOCIRepositoryArgs = newSourceOCIFlags()
func newSourceOCIFlags() sourceOCIRepositoryFlags { func newSourceOCIFlags() sourceOCIRepositoryFlags {
return 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 ignorePaths = &ignorePathsStr
} }
repository := &sourcev1.OCIRepository{ repository := &sourcev1b2.OCIRepository{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
Namespace: *kubeconfigArgs.Namespace, Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels, Labels: sourceLabels,
}, },
Spec: sourcev1.OCIRepositorySpec{ Spec: sourcev1b2.OCIRepositorySpec{
Provider: sourceOCIRepositoryArgs.provider.String(), Provider: sourceOCIRepositoryArgs.provider.String(),
URL: sourceOCIRepositoryArgs.url, URL: sourceOCIRepositoryArgs.url,
Insecure: sourceOCIRepositoryArgs.insecure, Insecure: sourceOCIRepositoryArgs.insecure,
Interval: metav1.Duration{ Interval: metav1.Duration{
Duration: createArgs.interval, Duration: createArgs.interval,
}, },
Reference: &sourcev1.OCIRepositoryRef{}, Reference: &sourcev1b2.OCIRepositoryRef{},
Ignore: ignorePaths, Ignore: ignorePaths,
}, },
} }
@ -228,13 +229,13 @@ func createSourceOCIRepositoryCmdRun(cmd *cobra.Command, args []string) error {
} }
func upsertOCIRepository(ctx context.Context, kubeClient client.Client, func upsertOCIRepository(ctx context.Context, kubeClient client.Client,
ociRepository *sourcev1.OCIRepository) (types.NamespacedName, error) { ociRepository *sourcev1b2.OCIRepository) (types.NamespacedName, error) {
namespacedName := types.NamespacedName{ namespacedName := types.NamespacedName{
Namespace: ociRepository.GetNamespace(), Namespace: ociRepository.GetNamespace(),
Name: ociRepository.GetName(), Name: ociRepository.GetName(),
} }
var existing sourcev1.OCIRepository var existing sourcev1b2.OCIRepository
err := kubeClient.Get(ctx, namespacedName, &existing) err := kubeClient.Get(ctx, namespacedName, &existing)
if err != nil { if err != nil {
if errors.IsNotFound(err) { if errors.IsNotFound(err) {

@ -21,7 +21,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "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{ var exportSourceHelmCmd = &cobra.Command{

@ -54,11 +54,11 @@ var getSourceAllCmd = &cobra.Command{
}, },
{ {
apiType: helmRepositoryType, apiType: helmRepositoryType,
list: &helmRepositoryListAdapter{&sourcev1b2.HelmRepositoryList{}}, list: &helmRepositoryListAdapter{&sourcev1.HelmRepositoryList{}},
}, },
{ {
apiType: helmChartType, apiType: helmChartType,
list: &helmChartListAdapter{&sourcev1b2.HelmChartList{}}, list: &helmChartListAdapter{&sourcev1.HelmChartList{}},
}, },
} }

@ -25,7 +25,7 @@ import (
"golang.org/x/text/language" "golang.org/x/text/language"
"k8s.io/apimachinery/pkg/runtime" "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" "github.com/fluxcd/flux2/v2/internal/utils"
) )

@ -26,7 +26,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "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" "github.com/fluxcd/flux2/v2/internal/utils"
) )

@ -19,11 +19,11 @@ package main
import ( import (
"fmt" "fmt"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
helmv2 "github.com/fluxcd/helm-controller/api/v2beta2" helmv2 "github.com/fluxcd/helm-controller/api/v2beta2"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
) )
var reconcileHrCmd = &cobra.Command{ var reconcileHrCmd = &cobra.Command{
@ -70,7 +70,7 @@ func (obj helmReleaseAdapter) reconcileSource() bool {
func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName) { func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName) {
cmd := reconcileWithSourceCommand{ cmd := reconcileWithSourceCommand{
apiType: helmChartType, apiType: helmChartType,
object: helmChartAdapter{&sourcev1b2.HelmChart{}}, object: helmChartAdapter{&sourcev1.HelmChart{}},
force: true, force: true,
} }

@ -33,10 +33,10 @@ var reconcileSourceHelmChartCmd = &cobra.Command{
# Trigger a reconciliation of the HelmCharts's source and apply changes # Trigger a reconciliation of the HelmCharts's source and apply changes
flux reconcile helmchart podinfo --with-source`, flux reconcile helmchart podinfo --with-source`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1b2.GroupVersion.WithKind(sourcev1b2.HelmChartKind)), ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1b2.HelmChartKind)),
RunE: reconcileWithSourceCommand{ RunE: reconcileWithSourceCommand{
apiType: helmChartType, apiType: helmChartType,
object: helmChartAdapter{&sourcev1b2.HelmChart{}}, object: helmChartAdapter{&sourcev1.HelmChart{}},
}.run, }.run,
} }
@ -62,10 +62,10 @@ func (obj helmChartAdapter) reconcileSource() bool {
func (obj helmChartAdapter) getSource() (reconcileSource, types.NamespacedName) { func (obj helmChartAdapter) getSource() (reconcileSource, types.NamespacedName) {
var cmd reconcileCommand var cmd reconcileCommand
switch obj.Spec.SourceRef.Kind { switch obj.Spec.SourceRef.Kind {
case sourcev1b2.HelmRepositoryKind: case sourcev1.HelmRepositoryKind:
cmd = reconcileCommand{ cmd = reconcileCommand{
apiType: helmRepositoryType, apiType: helmRepositoryType,
object: helmRepositoryAdapter{&sourcev1b2.HelmRepository{}}, object: helmRepositoryAdapter{&sourcev1.HelmRepository{}},
} }
case sourcev1.GitRepositoryKind: case sourcev1.GitRepositoryKind:
cmd = reconcileCommand{ cmd = reconcileCommand{

@ -23,7 +23,7 @@ import (
"github.com/fluxcd/pkg/apis/meta" "github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/pkg/runtime/conditions" "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{ var reconcileSourceHelmCmd = &cobra.Command{

@ -21,7 +21,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" sourcev1 "github.com/fluxcd/source-controller/api/v1"
) )
var resumeSourceHelmChartCmd = &cobra.Command{ var resumeSourceHelmChartCmd = &cobra.Command{

@ -19,7 +19,7 @@ package main
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" sourcev1 "github.com/fluxcd/source-controller/api/v1"
) )
var resumeSourceHelmCmd = &cobra.Command{ var resumeSourceHelmCmd = &cobra.Command{

@ -95,16 +95,16 @@ func (a bucketListAdapter) len() int {
return len(a.BucketList.Items) return len(a.BucketList.Items)
} }
// sourcev1b2.HelmChart // sourcev1.HelmChart
var helmChartType = apiType{ var helmChartType = apiType{
kind: sourcev1b2.HelmChartKind, kind: sourcev1.HelmChartKind,
humanKind: "source chart", humanKind: "source chart",
groupVersion: sourcev1b2.GroupVersion, groupVersion: sourcev1.GroupVersion,
} }
type helmChartAdapter struct { type helmChartAdapter struct {
*sourcev1b2.HelmChart *sourcev1.HelmChart
} }
func (a helmChartAdapter) asClientObject() client.Object { func (a helmChartAdapter) asClientObject() client.Object {
@ -115,10 +115,10 @@ func (a helmChartAdapter) deepCopyClientObject() client.Object {
return a.HelmChart.DeepCopy() return a.HelmChart.DeepCopy()
} }
// sourcev1b2.HelmChartList // sourcev1.HelmChartList
type helmChartListAdapter struct { type helmChartListAdapter struct {
*sourcev1b2.HelmChartList *sourcev1.HelmChartList
} }
func (a helmChartListAdapter) asClientList() client.ObjectList { func (a helmChartListAdapter) asClientList() client.ObjectList {
@ -163,16 +163,16 @@ func (a gitRepositoryListAdapter) len() int {
return len(a.GitRepositoryList.Items) return len(a.GitRepositoryList.Items)
} }
// sourcev1b2.HelmRepository // sourcev1.HelmRepository
var helmRepositoryType = apiType{ var helmRepositoryType = apiType{
kind: sourcev1b2.HelmRepositoryKind, kind: sourcev1.HelmRepositoryKind,
humanKind: "source helm", humanKind: "source helm",
groupVersion: sourcev1b2.GroupVersion, groupVersion: sourcev1.GroupVersion,
} }
type helmRepositoryAdapter struct { type helmRepositoryAdapter struct {
*sourcev1b2.HelmRepository *sourcev1.HelmRepository
} }
func (a helmRepositoryAdapter) asClientObject() client.Object { func (a helmRepositoryAdapter) asClientObject() client.Object {
@ -183,10 +183,10 @@ func (a helmRepositoryAdapter) deepCopyClientObject() client.Object {
return a.HelmRepository.DeepCopy() return a.HelmRepository.DeepCopy()
} }
// sourcev1b2.HelmRepositoryList // sourcev1.HelmRepositoryList
type helmRepositoryListAdapter struct { type helmRepositoryListAdapter struct {
*sourcev1b2.HelmRepositoryList *sourcev1.HelmRepositoryList
} }
func (a helmRepositoryListAdapter) asClientList() client.ObjectList { func (a helmRepositoryListAdapter) asClientList() client.ObjectList {

@ -19,7 +19,7 @@ package main
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" sourcev1 "github.com/fluxcd/source-controller/api/v1"
) )
var suspendSourceHelmChartCmd = &cobra.Command{ var suspendSourceHelmChartCmd = &cobra.Command{

@ -19,7 +19,7 @@ package main
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" sourcev1 "github.com/fluxcd/source-controller/api/v1"
) )
var suspendSourceHelmCmd = &cobra.Command{ var suspendSourceHelmCmd = &cobra.Command{

@ -1,5 +1,5 @@
--- ---
apiVersion: source.toolkit.fluxcd.io/v1beta2 apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository kind: HelmRepository
metadata: metadata:
name: podinfo name: podinfo

@ -1,5 +1,5 @@
--- ---
apiVersion: source.toolkit.fluxcd.io/v1beta2 apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository kind: HelmRepository
metadata: metadata:
name: podinfo name: podinfo

@ -1,5 +1,5 @@
--- ---
apiVersion: source.toolkit.fluxcd.io/v1beta2 apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository kind: HelmRepository
metadata: metadata:
name: podinfo name: podinfo

@ -1,5 +1,5 @@
--- ---
apiVersion: source.toolkit.fluxcd.io/v1beta2 apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository kind: HelmRepository
metadata: metadata:
name: flux-system name: flux-system

Loading…
Cancel
Save