Update CLI to OCIRepository v1 (GA)

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
pull/5371/head
Stefan Prodan 2 weeks ago
parent b37ba736fa
commit 79fed691ca
No known key found for this signature in database
GPG Key ID: 3299AEB0E4085BAF

@ -37,7 +37,6 @@ import (
"github.com/fluxcd/pkg/apis/meta" "github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/pkg/runtime/transform" "github.com/fluxcd/pkg/runtime/transform"
sourcev1 "github.com/fluxcd/source-controller/api/v1" 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"
@ -142,7 +141,7 @@ var helmReleaseArgs helmReleaseFlags
var supportedHelmReleaseValuesFromKinds = []string{"Secret", "ConfigMap"} var supportedHelmReleaseValuesFromKinds = []string{"Secret", "ConfigMap"}
var supportedHelmReleaseReferenceKinds = []string{sourcev1b2.OCIRepositoryKind, sourcev1.HelmChartKind} var supportedHelmReleaseReferenceKinds = []string{sourcev1.OCIRepositoryKind, sourcev1.HelmChartKind}
func init() { func init() {
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.name, "release-name", "", "name used for the Helm release, defaults to a composition of '[<target-namespace>-]<HelmRelease-name>'") createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.name, "release-name", "", "name used for the Helm release, defaults to a composition of '[<target-namespace>-]<HelmRelease-name>'")
@ -222,7 +221,7 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
} }
case helmReleaseArgs.chartRef != "": case helmReleaseArgs.chartRef != "":
kind, name, ns := utils.ParseObjectKindNameNamespace(helmReleaseArgs.chartRef) kind, name, ns := utils.ParseObjectKindNameNamespace(helmReleaseArgs.chartRef)
if kind != sourcev1.HelmChartKind && kind != sourcev1b2.OCIRepositoryKind { if kind != sourcev1.HelmChartKind && kind != sourcev1.OCIRepositoryKind {
return fmt.Errorf("chart reference kind '%s' is not supported, must be one of: %s", return fmt.Errorf("chart reference kind '%s' is not supported, must be one of: %s",
kind, strings.Join(supportedHelmReleaseReferenceKinds, ", ")) kind, strings.Join(supportedHelmReleaseReferenceKinds, ", "))
} }

@ -29,9 +29,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client"
"github.com/fluxcd/pkg/apis/meta" "github.com/fluxcd/pkg/apis/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1" 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"
@ -81,7 +79,7 @@ var sourceOCIRepositoryArgs = newSourceOCIFlags()
func newSourceOCIFlags() sourceOCIRepositoryFlags { func newSourceOCIFlags() sourceOCIRepositoryFlags {
return sourceOCIRepositoryFlags{ return sourceOCIRepositoryFlags{
provider: flags.SourceOCIProvider(sourcev1b2.GenericOCIProvider), provider: flags.SourceOCIProvider(sourcev1.GenericOCIProvider),
} }
} }
@ -127,20 +125,20 @@ func createSourceOCIRepositoryCmdRun(cmd *cobra.Command, args []string) error {
ignorePaths = &ignorePathsStr ignorePaths = &ignorePathsStr
} }
repository := &sourcev1b2.OCIRepository{ repository := &sourcev1.OCIRepository{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
Namespace: *kubeconfigArgs.Namespace, Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels, Labels: sourceLabels,
}, },
Spec: sourcev1b2.OCIRepositorySpec{ Spec: sourcev1.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: &sourcev1b2.OCIRepositoryRef{}, Reference: &sourcev1.OCIRepositoryRef{},
Ignore: ignorePaths, Ignore: ignorePaths,
}, },
} }
@ -237,13 +235,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 *sourcev1b2.OCIRepository) (types.NamespacedName, error) { ociRepository *sourcev1.OCIRepository) (types.NamespacedName, error) {
namespacedName := types.NamespacedName{ namespacedName := types.NamespacedName{
Namespace: ociRepository.GetNamespace(), Namespace: ociRepository.GetNamespace(),
Name: ociRepository.GetName(), Name: ociRepository.GetName(),
} }
var existing sourcev1b2.OCIRepository var existing sourcev1.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) {

@ -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 deleteSourceChartCmd = &cobra.Command{ var deleteSourceChartCmd = &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 deleteSourceOCIRepositoryCmd = &cobra.Command{ var deleteSourceOCIRepositoryCmd = &cobra.Command{

@ -22,7 +22,7 @@ import (
"os" "os"
"github.com/fluxcd/pkg/oci" "github.com/fluxcd/pkg/oci"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" sourcev1 "github.com/fluxcd/source-controller/api/v1"
"github.com/google/go-containerregistry/pkg/crane" "github.com/google/go-containerregistry/pkg/crane"
"github.com/spf13/cobra" "github.com/spf13/cobra"

@ -46,7 +46,6 @@ import (
notificationv1 "github.com/fluxcd/notification-controller/api/v1" notificationv1 "github.com/fluxcd/notification-controller/api/v1"
notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3" notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/v2/internal/utils" "github.com/fluxcd/flux2/v2/internal/utils"
"github.com/fluxcd/flux2/v2/pkg/printers" "github.com/fluxcd/flux2/v2/pkg/printers"
@ -446,7 +445,7 @@ var fluxKindMap = refMap{
field: []string{"spec", "sourceRef"}, field: []string{"spec", "sourceRef"},
}, },
sourcev1.GitRepositoryKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)}, sourcev1.GitRepositoryKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)},
sourcev1b2.OCIRepositoryKind: {gvk: sourcev1b2.GroupVersion.WithKind(sourcev1b2.OCIRepositoryKind)}, sourcev1.OCIRepositoryKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.OCIRepositoryKind)},
sourcev1.BucketKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)}, sourcev1.BucketKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)},
sourcev1.HelmRepositoryKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)}, sourcev1.HelmRepositoryKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)},
autov1.ImageUpdateAutomationKind: {gvk: autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)}, autov1.ImageUpdateAutomationKind: {gvk: autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)},

@ -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 exportSourceOCIRepositoryCmd = &cobra.Command{ var exportSourceOCIRepositoryCmd = &cobra.Command{

@ -21,7 +21,6 @@ import (
apimeta "k8s.io/apimachinery/pkg/api/meta" apimeta "k8s.io/apimachinery/pkg/api/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
) )
var getSourceAllCmd = &cobra.Command{ var getSourceAllCmd = &cobra.Command{
@ -42,7 +41,7 @@ var getSourceAllCmd = &cobra.Command{
var allSourceCmd = []getCommand{ var allSourceCmd = []getCommand{
{ {
apiType: ociRepositoryType, apiType: ociRepositoryType,
list: &ociRepositoryListAdapter{&sourcev1b2.OCIRepositoryList{}}, list: &ociRepositoryListAdapter{&sourcev1.OCIRepositoryList{}},
}, },
{ {
apiType: bucketType, apiType: bucketType,

@ -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"
) )

@ -24,7 +24,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/fluxcd/pkg/oci" "github.com/fluxcd/pkg/oci"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" sourcev1 "github.com/fluxcd/source-controller/api/v1"
"github.com/fluxcd/flux2/v2/internal/flags" "github.com/fluxcd/flux2/v2/internal/flags"
"github.com/fluxcd/flux2/v2/pkg/printers" "github.com/fluxcd/flux2/v2/pkg/printers"

@ -21,13 +21,13 @@ import (
"fmt" "fmt"
"os" "os"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/google/go-containerregistry/pkg/crane" "github.com/google/go-containerregistry/pkg/crane"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/fluxcd/flux2/v2/internal/flags"
"github.com/fluxcd/pkg/oci" "github.com/fluxcd/pkg/oci"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
"github.com/fluxcd/flux2/v2/internal/flags"
) )
var pullArtifactCmd = &cobra.Command{ var pullArtifactCmd = &cobra.Command{

@ -36,7 +36,7 @@ import (
authutils "github.com/fluxcd/pkg/auth/utils" authutils "github.com/fluxcd/pkg/auth/utils"
"github.com/fluxcd/pkg/oci" "github.com/fluxcd/pkg/oci"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" sourcev1 "github.com/fluxcd/source-controller/api/v1"
"github.com/fluxcd/flux2/v2/internal/flags" "github.com/fluxcd/flux2/v2/internal/flags"
) )

@ -24,7 +24,6 @@ import (
helmv2 "github.com/fluxcd/helm-controller/api/v2" helmv2 "github.com/fluxcd/helm-controller/api/v2"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
) )
var reconcileHrCmd = &cobra.Command{ var reconcileHrCmd = &cobra.Command{
@ -92,7 +91,7 @@ func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName
} }
return reconcileCommand{ return reconcileCommand{
apiType: ociRepositoryType, apiType: ociRepositoryType,
object: ociRepositoryAdapter{&sourcev1b2.OCIRepository{}}, object: ociRepositoryAdapter{&sourcev1.OCIRepository{}},
}, namespacedName }, namespacedName
default: default:
// default case assumes the HelmRelease is using a HelmChartTemplate // default case assumes the HelmRelease is using a HelmChartTemplate

@ -22,7 +22,6 @@ import (
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1" kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
) )
var reconcileKsCmd = &cobra.Command{ var reconcileKsCmd = &cobra.Command{
@ -66,10 +65,10 @@ func (obj kustomizationAdapter) reconcileSource() bool {
func (obj kustomizationAdapter) getSource() (reconcileSource, types.NamespacedName) { func (obj kustomizationAdapter) getSource() (reconcileSource, types.NamespacedName) {
var cmd reconcileCommand var cmd reconcileCommand
switch obj.Spec.SourceRef.Kind { switch obj.Spec.SourceRef.Kind {
case sourcev1b2.OCIRepositoryKind: case sourcev1.OCIRepositoryKind:
cmd = reconcileCommand{ cmd = reconcileCommand{
apiType: ociRepositoryType, apiType: ociRepositoryType,
object: ociRepositoryAdapter{&sourcev1b2.OCIRepository{}}, object: ociRepositoryAdapter{&sourcev1.OCIRepository{}},
} }
case sourcev1.GitRepositoryKind: case sourcev1.GitRepositoryKind:
cmd = reconcileCommand{ cmd = reconcileCommand{

@ -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 reconcileSourceOCIRepositoryCmd = &cobra.Command{ var reconcileSourceOCIRepositoryCmd = &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 resumeSourceOCIRepositoryCmd = &cobra.Command{ var resumeSourceOCIRepositoryCmd = &cobra.Command{

@ -20,7 +20,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
) )
// These are general-purpose adapters for attaching methods to, for // These are general-purpose adapters for attaching methods to, for
@ -30,13 +29,13 @@ import (
// sourcev1.ociRepository // sourcev1.ociRepository
var ociRepositoryType = apiType{ var ociRepositoryType = apiType{
kind: sourcev1b2.OCIRepositoryKind, kind: sourcev1.OCIRepositoryKind,
humanKind: "source oci", humanKind: "source oci",
groupVersion: sourcev1b2.GroupVersion, groupVersion: sourcev1.GroupVersion,
} }
type ociRepositoryAdapter struct { type ociRepositoryAdapter struct {
*sourcev1b2.OCIRepository *sourcev1.OCIRepository
} }
func (a ociRepositoryAdapter) asClientObject() client.Object { func (a ociRepositoryAdapter) asClientObject() client.Object {
@ -50,7 +49,7 @@ func (a ociRepositoryAdapter) deepCopyClientObject() client.Object {
// sourcev1b2.OCIRepositoryList // sourcev1b2.OCIRepositoryList
type ociRepositoryListAdapter struct { type ociRepositoryListAdapter struct {
*sourcev1b2.OCIRepositoryList *sourcev1.OCIRepositoryList
} }
func (a ociRepositoryListAdapter) asClientList() client.ObjectList { func (a ociRepositoryListAdapter) asClientList() client.ObjectList {

@ -34,7 +34,6 @@ import (
notificationv1 "github.com/fluxcd/notification-controller/api/v1" notificationv1 "github.com/fluxcd/notification-controller/api/v1"
notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3" notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/v2/internal/utils" "github.com/fluxcd/flux2/v2/internal/utils"
"github.com/fluxcd/flux2/v2/pkg/printers" "github.com/fluxcd/flux2/v2/pkg/printers"
@ -82,9 +81,9 @@ func runStatsCmd(cmd *cobra.Command, args []string) error {
Group: sourcev1.GroupVersion.Group, Group: sourcev1.GroupVersion.Group,
}, },
{ {
Kind: sourcev1b2.OCIRepositoryKind, Kind: sourcev1.OCIRepositoryKind,
Version: sourcev1b2.GroupVersion.Version, Version: sourcev1.GroupVersion.Version,
Group: sourcev1b2.GroupVersion.Group, Group: sourcev1.GroupVersion.Group,
}, },
{ {
Kind: sourcev1.HelmRepositoryKind, Kind: sourcev1.HelmRepositoryKind,

@ -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 suspendSourceOCIRepositoryCmd = &cobra.Command{ var suspendSourceOCIRepositoryCmd = &cobra.Command{

@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/fluxcd/pkg/oci" "github.com/fluxcd/pkg/oci"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" sourcev1 "github.com/fluxcd/source-controller/api/v1"
"github.com/fluxcd/flux2/v2/internal/flags" "github.com/fluxcd/flux2/v2/internal/flags"
) )

@ -27,7 +27,7 @@ spec:
kind: HelmRepository kind: HelmRepository
name: podinfo name: podinfo
--- ---
apiVersion: source.toolkit.fluxcd.io/v1beta2 apiVersion: source.toolkit.fluxcd.io/v1
kind: OCIRepository kind: OCIRepository
metadata: metadata:
name: podinfo name: podinfo

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

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

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

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

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

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

@ -54,7 +54,7 @@ status:
type: Ready type: Ready
lastAttemptedRevision: 6.3.5 lastAttemptedRevision: 6.3.5
--- ---
apiVersion: source.toolkit.fluxcd.io/v1beta2 apiVersion: source.toolkit.fluxcd.io/v1
kind: OCIRepository kind: OCIRepository
metadata: metadata:
labels: labels:

@ -59,7 +59,7 @@ status:
type: Ready type: Ready
lastAppliedRevision: main@sha1:696f056df216eea4f9401adbee0ff744d4df390f lastAppliedRevision: main@sha1:696f056df216eea4f9401adbee0ff744d4df390f
--- ---
apiVersion: source.toolkit.fluxcd.io/v1beta2 apiVersion: source.toolkit.fluxcd.io/v1
kind: OCIRepository kind: OCIRepository
metadata: metadata:
labels: labels:

@ -38,7 +38,6 @@ import (
fluxmeta "github.com/fluxcd/pkg/apis/meta" fluxmeta "github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/pkg/oci" "github.com/fluxcd/pkg/oci"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/v2/internal/utils" "github.com/fluxcd/flux2/v2/internal/utils"
) )
@ -223,7 +222,7 @@ func traceKustomization(ctx context.Context, kubeClient client.Client, ksName ty
ksReady := meta.FindStatusCondition(ks.Status.Conditions, fluxmeta.ReadyCondition) ksReady := meta.FindStatusCondition(ks.Status.Conditions, fluxmeta.ReadyCondition)
var gitRepository *sourcev1.GitRepository var gitRepository *sourcev1.GitRepository
var ociRepository *sourcev1b2.OCIRepository var ociRepository *sourcev1.OCIRepository
var ksRepositoryReady *metav1.Condition var ksRepositoryReady *metav1.Condition
switch ks.Spec.SourceRef.Kind { switch ks.Spec.SourceRef.Kind {
case sourcev1.GitRepositoryKind: case sourcev1.GitRepositoryKind:
@ -240,8 +239,8 @@ func traceKustomization(ctx context.Context, kubeClient client.Client, ksName ty
return "", fmt.Errorf("failed to find GitRepository: %w", err) return "", fmt.Errorf("failed to find GitRepository: %w", err)
} }
ksRepositoryReady = meta.FindStatusCondition(gitRepository.Status.Conditions, fluxmeta.ReadyCondition) ksRepositoryReady = meta.FindStatusCondition(gitRepository.Status.Conditions, fluxmeta.ReadyCondition)
case sourcev1b2.OCIRepositoryKind: case sourcev1.OCIRepositoryKind:
ociRepository = &sourcev1b2.OCIRepository{} ociRepository = &sourcev1.OCIRepository{}
sourceNamespace := ks.Namespace sourceNamespace := ks.Namespace
if ks.Spec.SourceRef.Namespace != "" { if ks.Spec.SourceRef.Namespace != "" {
sourceNamespace = ks.Spec.SourceRef.Namespace sourceNamespace = ks.Spec.SourceRef.Namespace
@ -348,7 +347,7 @@ Status: Unknown
Kustomization *kustomizev1.Kustomization Kustomization *kustomizev1.Kustomization
KustomizationReady *metav1.Condition KustomizationReady *metav1.Condition
GitRepository *sourcev1.GitRepository GitRepository *sourcev1.GitRepository
OCIRepository *sourcev1b2.OCIRepository OCIRepository *sourcev1.OCIRepository
RepositoryReady *metav1.Condition RepositoryReady *metav1.Condition
Annotations map[string]string Annotations map[string]string
}{ }{
@ -403,13 +402,13 @@ func traceHelm(ctx context.Context, kubeClient client.Client, hrName types.Names
var hrGitRepositoryReady *metav1.Condition var hrGitRepositoryReady *metav1.Condition
var hrHelmRepository *sourcev1.HelmRepository var hrHelmRepository *sourcev1.HelmRepository
var hrHelmRepositoryReady *metav1.Condition var hrHelmRepositoryReady *metav1.Condition
var hrOCIRepository *sourcev1b2.OCIRepository var hrOCIRepository *sourcev1.OCIRepository
var hrOCIRepositoryReady *metav1.Condition var hrOCIRepositoryReady *metav1.Condition
if hr.Spec.Chart == nil { if hr.Spec.Chart == nil {
if hr.Spec.ChartRef != nil { if hr.Spec.ChartRef != nil {
switch hr.Spec.ChartRef.Kind { switch hr.Spec.ChartRef.Kind {
case sourcev1b2.OCIRepositoryKind: case sourcev1.OCIRepositoryKind:
hrOCIRepository = &sourcev1b2.OCIRepository{} hrOCIRepository = &sourcev1.OCIRepository{}
sourceNamespace := hr.Namespace sourceNamespace := hr.Namespace
if hr.Spec.ChartRef.Namespace != "" { if hr.Spec.ChartRef.Namespace != "" {
sourceNamespace = hr.Spec.ChartRef.Namespace sourceNamespace = hr.Spec.ChartRef.Namespace
@ -583,7 +582,7 @@ Status: Unknown
GitRepositoryReady *metav1.Condition GitRepositoryReady *metav1.Condition
HelmRepository *sourcev1.HelmRepository HelmRepository *sourcev1.HelmRepository
HelmRepositoryReady *metav1.Condition HelmRepositoryReady *metav1.Condition
OCIRepository *sourcev1b2.OCIRepository OCIRepository *sourcev1.OCIRepository
OCIRepositoryReady *metav1.Condition OCIRepositoryReady *metav1.Condition
Annotations map[string]string Annotations map[string]string
}{ }{

@ -21,12 +21,11 @@ import (
"strings" "strings"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/v2/internal/utils" "github.com/fluxcd/flux2/v2/internal/utils"
) )
var supportedKustomizationSourceKinds = []string{sourcev1b2.OCIRepositoryKind, sourcev1.GitRepositoryKind, sourcev1.BucketKind} var supportedKustomizationSourceKinds = []string{sourcev1.OCIRepositoryKind, sourcev1.GitRepositoryKind, sourcev1.BucketKind}
type KustomizationSource struct { type KustomizationSource struct {
Kind string Kind string

@ -20,8 +20,9 @@ import (
"fmt" "fmt"
"strings" "strings"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
"github.com/fluxcd/flux2/v2/internal/utils" "github.com/fluxcd/flux2/v2/internal/utils"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
) )
var supportedSourceOCIProviders = []string{ var supportedSourceOCIProviders = []string{

@ -51,7 +51,6 @@ import (
runclient "github.com/fluxcd/pkg/runtime/client" runclient "github.com/fluxcd/pkg/runtime/client"
"github.com/fluxcd/pkg/version" "github.com/fluxcd/pkg/version"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/v2/pkg/manifestgen/install" "github.com/fluxcd/flux2/v2/pkg/manifestgen/install"
) )
@ -128,7 +127,6 @@ func NewScheme() *apiruntime.Scheme {
_ = rbacv1.AddToScheme(scheme) _ = rbacv1.AddToScheme(scheme)
_ = appsv1.AddToScheme(scheme) _ = appsv1.AddToScheme(scheme)
_ = networkingv1.AddToScheme(scheme) _ = networkingv1.AddToScheme(scheme)
_ = sourcev1b2.AddToScheme(scheme)
_ = sourcev1.AddToScheme(scheme) _ = sourcev1.AddToScheme(scheme)
_ = kustomizev1.AddToScheme(scheme) _ = kustomizev1.AddToScheme(scheme)
_ = helmv2.AddToScheme(scheme) _ = helmv2.AddToScheme(scheme)

@ -268,7 +268,7 @@ func objectReconciled(kube client.Client, objKey client.ObjectKey, clientObject
func hasRevision(kind string, obj map[string]interface{}, expectedRev string) (bool, error) { func hasRevision(kind string, obj map[string]interface{}, expectedRev string) (bool, error) {
var rev string var rev string
switch kind { switch kind {
case sourcev1.GitRepositoryKind, sourcev1b2.OCIRepositoryKind, sourcev1.BucketKind, sourcev1.HelmChartKind: case sourcev1.GitRepositoryKind, sourcev1.OCIRepositoryKind, sourcev1.BucketKind, sourcev1.HelmChartKind:
rev, _, _ = unstructured.NestedString(obj, "status", "artifact", "revision") rev, _, _ = unstructured.NestedString(obj, "status", "artifact", "revision")
case kustomizev1.KustomizationKind: case kustomizev1.KustomizationKind:
rev, _, _ = unstructured.NestedString(obj, "status", "lastAttemptedRevision") rev, _, _ = unstructured.NestedString(obj, "status", "lastAttemptedRevision")

@ -27,11 +27,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/client/fake"
"github.com/fluxcd/flux2/v2/internal/utils"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1" kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2" notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/v2/internal/utils"
) )
func Test_hasRevision(t *testing.T) { func Test_hasRevision(t *testing.T) {
@ -98,11 +98,11 @@ func Test_hasRevision(t *testing.T) {
}, },
{ {
name: "OCIRepository revision", name: "OCIRepository revision",
obj: &sourcev1b2.OCIRepository{ obj: &sourcev1.OCIRepository{
TypeMeta: metav1.TypeMeta{ TypeMeta: metav1.TypeMeta{
Kind: sourcev1b2.OCIRepositoryKind, Kind: sourcev1.OCIRepositoryKind,
}, },
Status: sourcev1b2.OCIRepositoryStatus{ Status: sourcev1.OCIRepositoryStatus{
Artifact: &sourcev1.Artifact{ Artifact: &sourcev1.Artifact{
Revision: "main@sha1:5bf3a8f9bb0aa5ae8afd6208f43757ab73fc033a", Revision: "main@sha1:5bf3a8f9bb0aa5ae8afd6208f43757ab73fc033a",
}, },

@ -35,7 +35,6 @@ import (
notificationv1 "github.com/fluxcd/notification-controller/api/v1" notificationv1 "github.com/fluxcd/notification-controller/api/v1"
notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3" notificationv1b3 "github.com/fluxcd/notification-controller/api/v1beta3"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/v2/pkg/log" "github.com/fluxcd/flux2/v2/pkg/log"
"github.com/fluxcd/flux2/v2/pkg/manifestgen" "github.com/fluxcd/flux2/v2/pkg/manifestgen"
@ -154,7 +153,7 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
} }
} }
{ {
var list sourcev1b2.OCIRepositoryList var list sourcev1.OCIRepositoryList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil { if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for i := range list.Items { for i := range list.Items {
r := list.Items[i] r := list.Items[i]

@ -38,7 +38,6 @@ import (
notiv1beta3 "github.com/fluxcd/notification-controller/api/v1beta3" notiv1beta3 "github.com/fluxcd/notification-controller/api/v1beta3"
"github.com/fluxcd/pkg/git" "github.com/fluxcd/pkg/git"
sourcev1 "github.com/fluxcd/source-controller/api/v1" sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/test-infra/tftestenv" "github.com/fluxcd/test-infra/tftestenv"
) )
@ -165,7 +164,6 @@ type providerConfig struct {
func init() { func init() {
utilruntime.Must(sourcev1.AddToScheme(scheme.Scheme)) utilruntime.Must(sourcev1.AddToScheme(scheme.Scheme))
utilruntime.Must(sourcev1beta2.AddToScheme(scheme.Scheme))
utilruntime.Must(kustomizev1.AddToScheme(scheme.Scheme)) utilruntime.Must(kustomizev1.AddToScheme(scheme.Scheme))
utilruntime.Must(helmv2.AddToScheme(scheme.Scheme)) utilruntime.Must(helmv2.AddToScheme(scheme.Scheme))
utilruntime.Must(reflectorv1.AddToScheme(scheme.Scheme)) utilruntime.Must(reflectorv1.AddToScheme(scheme.Scheme))

Loading…
Cancel
Save