Skip to content

Commit

Permalink
Merge pull request #5008 from fluxcd/bucket-ga
Browse files Browse the repository at this point in the history
Promote `bucket` commands to GA
  • Loading branch information
stefanprodan authored Sep 27, 2024
2 parents 0d101e0 + c7daf64 commit 2c7d781
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 73 deletions.
8 changes: 4 additions & 4 deletions cmd/flux/create_source_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

"github.com/fluxcd/pkg/apis/meta"

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/utils"
Expand All @@ -41,8 +41,8 @@ import (
var createSourceBucketCmd = &cobra.Command{
Use: "bucket [name]",
Short: "Create or update a Bucket source",
Long: withPreviewNote(`The create source bucket command generates a Bucket resource and waits for it to be downloaded.
For Buckets with static authentication, the credentials are stored in a Kubernetes secret.`),
Long: `The create source bucket command generates a Bucket resource and waits for it to be downloaded.
For Buckets with static authentication, the credentials are stored in a Kubernetes secret.`,
Example: ` # Create a source for a Bucket using static authentication
flux create source bucket podinfo \
--bucket-name=podinfo \
Expand Down Expand Up @@ -92,7 +92,7 @@ func init() {

func newSourceBucketFlags() sourceBucketFlags {
return sourceBucketFlags{
provider: flags.SourceBucketProvider(sourcev1.GenericBucketProvider),
provider: flags.SourceBucketProvider(sourcev1.BucketProviderGeneric),
}
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/delete_source_bucket.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 deleteSourceBucketCmd = &cobra.Command{
Use: "bucket [name]",
Short: "Delete a Bucket source",
Long: withPreviewNote("The delete source bucket command deletes the given Bucket from the cluster."),
Long: "The delete source bucket command deletes the given Bucket from the cluster.",
Example: ` # Delete a Bucket source
flux delete source bucket podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)),
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ var fluxKindMap = refMap{
},
sourcev1.GitRepositoryKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)},
sourcev1b2.OCIRepositoryKind: {gvk: sourcev1b2.GroupVersion.WithKind(sourcev1b2.OCIRepositoryKind)},
sourcev1b2.BucketKind: {gvk: sourcev1b2.GroupVersion.WithKind(sourcev1b2.BucketKind)},
sourcev1.BucketKind: {gvk: sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)},
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_bucket.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 exportSourceBucketCmd = &cobra.Command{
Use: "bucket [name]",
Short: "Export Bucket sources in YAML format",
Long: withPreviewNote("The export source git command exports one or all Bucket sources in YAML format."),
Long: "The export source git command exports one or all Bucket sources in YAML format.",
Example: ` # Export all Bucket sources
flux export source bucket --all > sources.yaml
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/get_source_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var getSourceAllCmd = &cobra.Command{
},
{
apiType: bucketType,
list: &bucketListAdapter{&sourcev1b2.BucketList{}},
list: &bucketListAdapter{&sourcev1.BucketList{}},
},
{
apiType: gitRepositoryType,
Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/get_source_bucket.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 getSourceBucketCmd = &cobra.Command{
Use: "bucket",
Short: "Get Bucket source statuses",
Long: withPreviewNote("The get sources bucket command prints the status of the Bucket sources."),
Long: "The get sources bucket command prints the status of the Bucket sources.",
Example: ` # List all Buckets and their status
flux get sources bucket
Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/reconcile_kustomization.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func (obj kustomizationAdapter) getSource() (reconcileSource, types.NamespacedNa
apiType: gitRepositoryType,
object: gitRepositoryAdapter{&sourcev1.GitRepository{}},
}
case sourcev1b2.BucketKind:
case sourcev1.BucketKind:
cmd = reconcileCommand{
apiType: bucketType,
object: bucketAdapter{&sourcev1b2.Bucket{}},
object: bucketAdapter{&sourcev1.Bucket{}},
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/reconcile_source_bucket.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 reconcileSourceBucketCmd = &cobra.Command{
Expand Down
5 changes: 2 additions & 3 deletions cmd/flux/reconcile_source_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"k8s.io/apimachinery/pkg/types"

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

var reconcileSourceHelmChartCmd = &cobra.Command{
Expand Down Expand Up @@ -72,10 +71,10 @@ func (obj helmChartAdapter) getSource() (reconcileSource, types.NamespacedName)
apiType: gitRepositoryType,
object: gitRepositoryAdapter{&sourcev1.GitRepository{}},
}
case sourcev1b2.BucketKind:
case sourcev1.BucketKind:
cmd = reconcileCommand{
apiType: bucketType,
object: bucketAdapter{&sourcev1b2.Bucket{}},
object: bucketAdapter{&sourcev1.Bucket{}},
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/resume_source_bucket.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 resumeSourceBucketCmd = &cobra.Command{
Expand Down
12 changes: 6 additions & 6 deletions cmd/flux/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ func (a ociRepositoryListAdapter) len() int {
return len(a.OCIRepositoryList.Items)
}

// sourcev1b2.Bucket
// sourcev1.Bucket

var bucketType = apiType{
kind: sourcev1b2.BucketKind,
kind: sourcev1.BucketKind,
humanKind: "source bucket",
groupVersion: sourcev1b2.GroupVersion,
groupVersion: sourcev1.GroupVersion,
}

type bucketAdapter struct {
*sourcev1b2.Bucket
*sourcev1.Bucket
}

func (a bucketAdapter) asClientObject() client.Object {
Expand All @@ -81,10 +81,10 @@ func (a bucketAdapter) deepCopyClientObject() client.Object {
return a.Bucket.DeepCopy()
}

// sourcev1b2.BucketList
// sourcev1.BucketList

type bucketListAdapter struct {
*sourcev1b2.BucketList
*sourcev1.BucketList
}

func (a bucketListAdapter) asClientList() client.ObjectList {
Expand Down
6 changes: 3 additions & 3 deletions cmd/flux/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ func runStatsCmd(cmd *cobra.Command, args []string) error {
Group: sourcev1.GroupVersion.Group,
},
{
Kind: sourcev1b2.BucketKind,
Version: sourcev1b2.GroupVersion.Version,
Group: sourcev1b2.GroupVersion.Group,
Kind: sourcev1.BucketKind,
Version: sourcev1.GroupVersion.Version,
Group: sourcev1.GroupVersion.Group,
},
{
Kind: kustomizev1.KustomizationKind,
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/suspend_source_bucket.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 suspendSourceBucketCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/testdata/export/bucket.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
apiVersion: source.toolkit.fluxcd.io/v1
kind: Bucket
metadata:
name: flux-system
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/testdata/export/objects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ spec:
name: flux-systen
namespace: {{ .fluxns }}
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
apiVersion: source.toolkit.fluxcd.io/v1
kind: Bucket
metadata:
name: flux-system
Expand Down
3 changes: 1 addition & 2 deletions internal/flags/helm_chart_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import (
"strings"

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

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

var supportedHelmChartSourceKinds = []string{sourcev1.HelmRepositoryKind, sourcev1.GitRepositoryKind, sourcev1b2.BucketKind}
var supportedHelmChartSourceKinds = []string{sourcev1.HelmRepositoryKind, sourcev1.GitRepositoryKind, sourcev1.BucketKind}

type HelmChartSource struct {
Kind string
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/kustomization_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/fluxcd/flux2/v2/internal/utils"
)

var supportedKustomizationSourceKinds = []string{sourcev1b2.OCIRepositoryKind, sourcev1.GitRepositoryKind, sourcev1b2.BucketKind}
var supportedKustomizationSourceKinds = []string{sourcev1b2.OCIRepositoryKind, sourcev1.GitRepositoryKind, sourcev1.BucketKind}

type KustomizationSource struct {
Kind string
Expand Down
11 changes: 6 additions & 5 deletions internal/flags/source_bucket_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ import (
"fmt"
"strings"

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

"github.com/fluxcd/flux2/v2/internal/utils"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
)

var supportedSourceBucketProviders = []string{
sourcev1.GenericBucketProvider,
sourcev1.AmazonBucketProvider,
sourcev1.AzureBucketProvider,
sourcev1.GoogleBucketProvider,
sourcev1.BucketProviderGeneric,
sourcev1.BucketProviderAmazon,
sourcev1.BucketProviderAzure,
sourcev1.BucketProviderGoogle,
}

type SourceBucketProvider string
Expand Down
4 changes: 2 additions & 2 deletions internal/flags/source_bucket_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package flags
import (
"testing"

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

func TestSourceBucketProvider_Set(t *testing.T) {
Expand All @@ -32,7 +32,7 @@ func TestSourceBucketProvider_Set(t *testing.T) {
expect string
expectErr bool
}{
{"supported", sourcev1.GenericBucketProvider, sourcev1.GenericBucketProvider, false},
{"supported", sourcev1.BucketProviderGeneric, sourcev1.BucketProviderGeneric, false},
{"unsupported", "unsupported", "", true},
{"empty", "", "", true},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
var rev string
switch kind {
case sourcev1.GitRepositoryKind, sourcev1b2.OCIRepositoryKind, sourcev1b2.BucketKind, sourcev1.HelmChartKind:
case sourcev1.GitRepositoryKind, sourcev1b2.OCIRepositoryKind, sourcev1.BucketKind, sourcev1.HelmChartKind:
rev, _, _ = unstructured.NestedString(obj, "status", "artifact", "revision")
case kustomizev1.KustomizationKind:
rev, _, _ = unstructured.NestedString(obj, "status", "lastAttemptedRevision")
Expand Down
2 changes: 1 addition & 1 deletion pkg/uninstall/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func Finalizers(ctx context.Context, logger log.Logger, kubeClient client.Client
}
}
{
var list sourcev1b2.BucketList
var list sourcev1.BucketList
if err := kubeClient.List(ctx, &list, client.InNamespace("")); err == nil {
for i := range list.Items {
r := list.Items[i]
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ require (
github.com/fluxcd/kustomize-controller/api v1.3.0
github.com/fluxcd/notification-controller/api v1.3.0
github.com/fluxcd/pkg/apis/event v0.10.0
github.com/fluxcd/pkg/apis/meta v1.6.0
github.com/fluxcd/pkg/apis/meta v1.6.1
github.com/fluxcd/pkg/git v0.20.0
github.com/fluxcd/pkg/git/gogit v0.20.0
github.com/fluxcd/pkg/runtime v0.49.0
github.com/fluxcd/source-controller/api v1.3.0
github.com/fluxcd/source-controller/api v1.4.1
github.com/fluxcd/test-infra/tftestenv v0.0.0-20240805120810-5b91964f964f
github.com/go-git/go-git/v5 v5.12.0
github.com/google/go-containerregistry v0.20.2
Expand All @@ -25,9 +25,9 @@ require (
github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5
github.com/onsi/gomega v1.34.1
google.golang.org/grpc v1.65.0
k8s.io/api v0.31.0
k8s.io/apimachinery v0.31.0
k8s.io/client-go v0.31.0
k8s.io/api v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
sigs.k8s.io/controller-runtime v0.19.0
)

Expand Down Expand Up @@ -124,15 +124,15 @@ require (
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.24.0 // indirect
google.golang.org/api v0.189.0 // indirect
Expand Down
Loading

0 comments on commit 2c7d781

Please sign in to comment.