mirror of
https://github.com/fluxcd/flux2.git
synced 2025-10-28 05:04:48 +08:00
Update Helm Source APIs to v1 (GA)
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
@ -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"
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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{}},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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,
|
||||
}
|
||||
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||
apiVersion: source.toolkit.fluxcd.io/v1
|
||||
kind: HelmRepository
|
||||
metadata:
|
||||
name: podinfo
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||
apiVersion: source.toolkit.fluxcd.io/v1
|
||||
kind: HelmRepository
|
||||
metadata:
|
||||
name: podinfo
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||
apiVersion: source.toolkit.fluxcd.io/v1
|
||||
kind: HelmRepository
|
||||
metadata:
|
||||
name: podinfo
|
||||
|
||||
2
cmd/flux/testdata/export/helm-repo.yaml
vendored
2
cmd/flux/testdata/export/helm-repo.yaml
vendored
@ -1,5 +1,5 @@
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||
apiVersion: source.toolkit.fluxcd.io/v1
|
||||
kind: HelmRepository
|
||||
metadata:
|
||||
name: flux-system
|
||||
|
||||
Reference in New Issue
Block a user