Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Helm Source APIs to v1 (GA) #4759

Merged
merged 6 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/flux/create_secret_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
var createSecretHelmCmd = &cobra.Command{
Use: "helm [name]",
Short: "Create or update a Kubernetes secret for Helm repository authentication",
Long: withPreviewNote(`The create secret helm command generates a Kubernetes secret with basic authentication credentials.`),
Long: `The create secret helm command generates a Kubernetes secret with basic authentication credentials.`,
Example: ` # Create a Helm authentication secret on disk and encrypt it with Mozilla SOPS
flux create secret helm repo-auth \
--namespace=my-namespace \
Expand Down
8 changes: 4 additions & 4 deletions cmd/flux/create_source_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"net/url"
"os"

"github.com/fluxcd/pkg/apis/meta"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -32,7 +31,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"

sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/pkg/apis/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1"

"github.com/fluxcd/flux2/v2/internal/utils"
"github.com/fluxcd/flux2/v2/pkg/manifestgen/sourcesecret"
Expand All @@ -41,8 +41,8 @@ import (
var createSourceHelmCmd = &cobra.Command{
Use: "helm [name]",
Short: "Create or update a HelmRepository source",
Long: withPreviewNote(`The create source helm command generates a HelmRepository resource and waits for it to fetch the index.
For private Helm repositories, the basic authentication credentials are stored in a Kubernetes secret.`),
Long: `The create source helm command generates a HelmRepository resource and waits for it to fetch the index.
For private Helm repositories, the basic authentication credentials are stored in a Kubernetes secret.`,
Example: ` # Create a source for an HTTPS public Helm repository
flux create source helm podinfo \
--url=https://stefanprodan.github.io/podinfo \
Expand Down
15 changes: 8 additions & 7 deletions cmd/flux/create_source_oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -79,7 +80,7 @@ var sourceOCIRepositoryArgs = newSourceOCIFlags()

func newSourceOCIFlags() sourceOCIRepositoryFlags {
return sourceOCIRepositoryFlags{
provider: flags.SourceOCIProvider(sourcev1.GenericOCIProvider),
provider: flags.SourceOCIProvider(sourcev1b2.GenericOCIProvider),
}
}

Expand Down Expand Up @@ -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,
},
}
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/delete_source_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ package main
import (
"github.com/spf13/cobra"

sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
)

var deleteSourceHelmCmd = &cobra.Command{
Use: "helm [name]",
Short: "Delete a HelmRepository source",
Long: withPreviewNote("The delete source helm command deletes the given HelmRepository from the cluster."),
Long: "The delete source helm command deletes the given HelmRepository from the cluster.",
stefanprodan marked this conversation as resolved.
Show resolved Hide resolved
Example: ` # Delete a Helm repository
flux delete source helm podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)),
Expand Down
8 changes: 4 additions & 4 deletions cmd/flux/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ var fluxKindMap = refMap{
gvk: helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind),
crossNamespaced: true,
otherRefs: func(namespace, name string) []string {
return []string{fmt.Sprintf("%s/%s-%s", sourcev1b2.HelmChartKind, namespace, name)}
return []string{fmt.Sprintf("%s/%s-%s", sourcev1.HelmChartKind, namespace, name)}
},
field: []string{"spec", "chart", "spec", "sourceRef"},
},
Expand All @@ -440,15 +440,15 @@ var fluxKindMap = refMap{
crossNamespaced: true,
field: []string{"spec", "imageRepositoryRef"},
},
sourcev1b2.HelmChartKind: {
gvk: sourcev1b2.GroupVersion.WithKind(sourcev1b2.HelmChartKind),
sourcev1.HelmChartKind: {
gvk: sourcev1.GroupVersion.WithKind(sourcev1.HelmChartKind),
crossNamespaced: true,
field: []string{"spec", "sourceRef"},
},
sourcev1.GitRepositoryKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)},
sourcev1b2.OCIRepositoryKind: {gvk: sourcev1b2.GroupVersion.WithKind(sourcev1b2.OCIRepositoryKind)},
sourcev1b2.BucketKind: {gvk: sourcev1b2.GroupVersion.WithKind(sourcev1b2.BucketKind)},
sourcev1b2.HelmRepositoryKind: {gvk: sourcev1b2.GroupVersion.WithKind(sourcev1b2.HelmRepositoryKind)},
sourcev1.HelmRepositoryKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)},
autov1.ImageUpdateAutomationKind: {gvk: autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)},
imagev1.ImageRepositoryKind: {gvk: imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/export_source_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ 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{
Use: "helm [name]",
Short: "Export HelmRepository sources in YAML format",
Long: withPreviewNote("The export source git command exports one or all HelmRepository sources in YAML format."),
Long: "The export source git command exports one or all HelmRepository sources in YAML format.",
Example: ` # Export all HelmRepository sources
flux export source helm --all > sources.yaml

Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/get_source_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}},
},
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/get_source_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ 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"
)

var getSourceHelmChartCmd = &cobra.Command{
Use: "chart",
Short: "Get HelmChart statuses",
Long: withPreviewNote("The get sources chart command prints the status of the HelmCharts."),
Long: "The get sources chart command prints the status of the HelmCharts.",
Example: ` # List all Helm charts and their status
flux get sources chart

Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/get_source_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ 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"
)

var getSourceHelmCmd = &cobra.Command{
Use: "helm",
Short: "Get HelmRepository source statuses",
Long: withPreviewNote("The get sources helm command prints the status of the HelmRepository sources."),
Long: "The get sources helm command prints the status of the HelmRepository sources.",
Example: ` # List all Helm repositories and their status
flux get sources helm

Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/reconcile_helmrelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"k8s.io/apimachinery/pkg/types"

helmv2 "github.com/fluxcd/helm-controller/api/v2beta2"
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
)

var reconcileHrCmd = &cobra.Command{
Expand Down Expand Up @@ -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,
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/flux/reconcile_source_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(sourcev1.HelmChartKind)),
RunE: reconcileWithSourceCommand{
apiType: helmChartType,
object: helmChartAdapter{&sourcev1b2.HelmChart{}},
object: helmChartAdapter{&sourcev1.HelmChart{}},
}.run,
}

Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/reconcile_source_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
3 changes: 2 additions & 1 deletion cmd/flux/reconcile_with_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"

"github.com/fluxcd/flux2/v2/internal/utils"
"github.com/fluxcd/pkg/apis/meta"

"github.com/fluxcd/flux2/v2/internal/utils"
)

type reconcileWithSource interface {
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/resume_source_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/resume_source_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
24 changes: 12 additions & 12 deletions cmd/flux/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions cmd/flux/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ func runStatsCmd(cmd *cobra.Command, args []string) error {
Group: sourcev1b2.GroupVersion.Group,
},
{
Kind: sourcev1b2.HelmRepositoryKind,
Version: sourcev1b2.GroupVersion.Version,
Group: sourcev1b2.GroupVersion.Group,
Kind: sourcev1.HelmRepositoryKind,
Version: sourcev1.GroupVersion.Version,
Group: sourcev1.GroupVersion.Group,
},
{
Kind: sourcev1b2.HelmChartKind,
Version: sourcev1b2.GroupVersion.Version,
Group: sourcev1b2.GroupVersion.Group,
Kind: sourcev1.HelmChartKind,
Version: sourcev1.GroupVersion.Version,
Group: sourcev1.GroupVersion.Group,
},
{
Kind: sourcev1b2.BucketKind,
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/suspend_source_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/suspend_source_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Loading
Loading