diff --git a/cmd/flux/resume.go b/cmd/flux/resume.go index f7bc74af2225d91f1d89e24cf9b137cfebcd3c8e..f25e99bff2715c007b17af40829e6718c8b07983 100644 --- a/cmd/flux/resume.go +++ b/cmd/flux/resume.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" + "sigs.k8s.io/controller-runtime/pkg/client" "github.com/fluxcd/flux2/internal/utils" ) @@ -33,7 +34,15 @@ var resumeCmd = &cobra.Command{ Long: "The resume sub-commands resume a suspended resource.", } +type ResumeFlags struct { + all bool +} + +var resumeArgs ResumeFlags + func init() { + resumeCmd.PersistentFlags().BoolVarP(&resumeArgs.all, "all", "", false, + "suspend all resources in that namespace") rootCmd.AddCommand(resumeCmd) } @@ -47,13 +56,18 @@ type resumable interface { type resumeCommand struct { apiType object resumable + list listResumable +} + +type listResumable interface { + listAdapter + resumeItem(i int) resumable } func (resume resumeCommand) run(cmd *cobra.Command, args []string) error { - if len(args) < 1 { + if len(args) < 1 && !resumeArgs.all { return fmt.Errorf("%s name is required", resume.humanKind) } - name := args[0] ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout) defer cancel() @@ -63,29 +77,46 @@ func (resume resumeCommand) run(cmd *cobra.Command, args []string) error { return err } - namespacedName := types.NamespacedName{ - Namespace: rootArgs.namespace, - Name: name, + var listOpts []client.ListOption + listOpts = append(listOpts, client.InNamespace(rootArgs.namespace)) + if len(args) > 0 { + listOpts = append(listOpts, client.MatchingFields{ + "metadata.name": args[0], + }) } - err = kubeClient.Get(ctx, namespacedName, resume.object.asClientObject()) + err = kubeClient.List(ctx, resume.list.asClientList(), listOpts...) if err != nil { return err } - logger.Actionf("resuming %s %s in %s namespace", resume.humanKind, name, rootArgs.namespace) - resume.object.setUnsuspended() - if err := kubeClient.Update(ctx, resume.object.asClientObject()); err != nil { - return err + if resume.list.len() == 0 { + logger.Failuref("no %s objects found in %s namespace", resume.kind, rootArgs.namespace) + return nil } - logger.Successf("%s resumed", resume.humanKind) - logger.Waitingf("waiting for %s reconciliation", resume.kind) - if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout, - isReady(ctx, kubeClient, namespacedName, resume.object)); err != nil { - return err + for i := 0; i < resume.list.len(); i++ { + logger.Actionf("resuming %s %s in %s namespace", resume.humanKind, resume.list.resumeItem(i).asClientObject().GetName(), rootArgs.namespace) + resume.list.resumeItem(i).setUnsuspended() + if err := kubeClient.Update(ctx, resume.list.resumeItem(i).asClientObject()); err != nil { + return err + } + logger.Successf("%s resumed", resume.humanKind) + + namespacedName := types.NamespacedName{ + Name: resume.list.resumeItem(i).asClientObject().GetName(), + Namespace: rootArgs.namespace, + } + + logger.Waitingf("waiting for %s reconciliation", resume.kind) + if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout, + isReady(ctx, kubeClient, namespacedName, resume.list.resumeItem(i))); err != nil { + logger.Failuref(err.Error()) + continue + } + logger.Successf("%s reconciliation completed", resume.kind) + logger.Successf(resume.list.resumeItem(i).successMessage()) } - logger.Successf("%s reconciliation completed", resume.kind) - logger.Successf(resume.object.successMessage()) + return nil } diff --git a/cmd/flux/resume_alert.go b/cmd/flux/resume_alert.go index b221ca0ef7b57959e036bb263fae5a779e5aca75..de5a645a7b2e07b8ff15ea7a4b5b5a51554a79a2 100644 --- a/cmd/flux/resume_alert.go +++ b/cmd/flux/resume_alert.go @@ -32,6 +32,7 @@ finish the apply.`, RunE: resumeCommand{ apiType: alertType, object: alertAdapter{¬ificationv1.Alert{}}, + list: &alertListAdapter{¬ificationv1.AlertList{}}, }.run, } @@ -50,3 +51,7 @@ func (obj alertAdapter) setUnsuspended() { func (obj alertAdapter) successMessage() string { return "Alert reconciliation completed" } + +func (a alertListAdapter) resumeItem(i int) resumable { + return &alertAdapter{&a.AlertList.Items[i]} +} diff --git a/cmd/flux/resume_helmrelease.go b/cmd/flux/resume_helmrelease.go index e2cff0fbd4f84f4ca017638056936c8273ec9b78..24ee8010fce798ef2e8b20dd897103c7d0907ab9 100644 --- a/cmd/flux/resume_helmrelease.go +++ b/cmd/flux/resume_helmrelease.go @@ -35,6 +35,7 @@ finish the apply.`, RunE: resumeCommand{ apiType: helmReleaseType, object: helmReleaseAdapter{&helmv2.HelmRelease{}}, + list: helmReleaseListAdapter{&helmv2.HelmReleaseList{}}, }.run, } @@ -53,3 +54,7 @@ func (obj helmReleaseAdapter) setUnsuspended() { func (obj helmReleaseAdapter) successMessage() string { return fmt.Sprintf("applied revision %s", obj.Status.LastAppliedRevision) } + +func (a helmReleaseListAdapter) resumeItem(i int) resumable { + return &helmReleaseAdapter{&a.HelmReleaseList.Items[i]} +} diff --git a/cmd/flux/resume_image_repository.go b/cmd/flux/resume_image_repository.go index 3153a17482c8d48a7976e78a112004686b8515f3..3538a1508f2bd8d368aa6c9bced5da1bcc55389a 100644 --- a/cmd/flux/resume_image_repository.go +++ b/cmd/flux/resume_image_repository.go @@ -31,6 +31,7 @@ var resumeImageRepositoryCmd = &cobra.Command{ RunE: resumeCommand{ apiType: imageRepositoryType, object: imageRepositoryAdapter{&imagev1.ImageRepository{}}, + list: imageRepositoryListAdapter{&imagev1.ImageRepositoryList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj imageRepositoryAdapter) getObservedGeneration() int64 { func (obj imageRepositoryAdapter) setUnsuspended() { obj.ImageRepository.Spec.Suspend = false } + +func (a imageRepositoryListAdapter) resumeItem(i int) resumable { + return &imageRepositoryAdapter{&a.ImageRepositoryList.Items[i]} +} diff --git a/cmd/flux/resume_image_updateauto.go b/cmd/flux/resume_image_updateauto.go index 2d92d54ef0241e126de7e1ea29eb13bb38eec6ff..79368ddcfeb232e2f5e1f1a2397116a2999ddc4e 100644 --- a/cmd/flux/resume_image_updateauto.go +++ b/cmd/flux/resume_image_updateauto.go @@ -31,6 +31,7 @@ var resumeImageUpdateCmd = &cobra.Command{ RunE: resumeCommand{ apiType: imageUpdateAutomationType, object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}}, + list: imageUpdateAutomationListAdapter{&autov1.ImageUpdateAutomationList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj imageUpdateAutomationAdapter) setUnsuspended() { func (obj imageUpdateAutomationAdapter) getObservedGeneration() int64 { return obj.ImageUpdateAutomation.Status.ObservedGeneration } + +func (a imageUpdateAutomationListAdapter) resumeItem(i int) resumable { + return &imageUpdateAutomationAdapter{&a.ImageUpdateAutomationList.Items[i]} +} diff --git a/cmd/flux/resume_kustomization.go b/cmd/flux/resume_kustomization.go index ac2def275710a6d352aa62a81870e3af0e86d49b..1555cc9a32b3279adf28d7871c5b3ccd1a065ba0 100644 --- a/cmd/flux/resume_kustomization.go +++ b/cmd/flux/resume_kustomization.go @@ -35,6 +35,7 @@ finish the apply.`, RunE: resumeCommand{ apiType: kustomizationType, object: kustomizationAdapter{&kustomizev1.Kustomization{}}, + list: kustomizationListAdapter{&kustomizev1.KustomizationList{}}, }.run, } @@ -53,3 +54,7 @@ func (obj kustomizationAdapter) setUnsuspended() { func (obj kustomizationAdapter) successMessage() string { return fmt.Sprintf("applied revision %s", obj.Status.LastAppliedRevision) } + +func (a kustomizationListAdapter) resumeItem(i int) resumable { + return &kustomizationAdapter{&a.KustomizationList.Items[i]} +} diff --git a/cmd/flux/resume_receiver.go b/cmd/flux/resume_receiver.go index 7bf37577b1a76dd1288716c6bca01bb6baab0a3a..eecfe63d9fc7aee70bd87715e4d0fedc38a2dbe6 100644 --- a/cmd/flux/resume_receiver.go +++ b/cmd/flux/resume_receiver.go @@ -32,6 +32,7 @@ finish the apply.`, RunE: resumeCommand{ apiType: receiverType, object: receiverAdapter{¬ificationv1.Receiver{}}, + list: receiverListAdapter{¬ificationv1.ReceiverList{}}, }.run, } @@ -50,3 +51,7 @@ func (obj receiverAdapter) setUnsuspended() { func (obj receiverAdapter) successMessage() string { return "Receiver reconciliation completed" } + +func (a receiverListAdapter) resumeItem(i int) resumable { + return &receiverAdapter{&a.ReceiverList.Items[i]} +} diff --git a/cmd/flux/resume_source_bucket.go b/cmd/flux/resume_source_bucket.go index a7a811244a3c5af9d3e51347a1ef60fcfd889ad1..e40cef344a7628c6f12fc6f6d92045f6e43f6653 100644 --- a/cmd/flux/resume_source_bucket.go +++ b/cmd/flux/resume_source_bucket.go @@ -45,3 +45,7 @@ func (obj bucketAdapter) getObservedGeneration() int64 { func (obj bucketAdapter) setUnsuspended() { obj.Bucket.Spec.Suspend = false } + +func (a bucketListAdapter) resumeItem(i int) resumable { + return &bucketAdapter{&a.BucketList.Items[i]} +} diff --git a/cmd/flux/resume_source_chart.go b/cmd/flux/resume_source_chart.go index f2cf59a034905edc4bd466357e2f5454157d5903..d3525eb3c8045629dcd1b72ddc381d092b8fff5a 100644 --- a/cmd/flux/resume_source_chart.go +++ b/cmd/flux/resume_source_chart.go @@ -33,6 +33,7 @@ var resumeSourceHelmChartCmd = &cobra.Command{ RunE: resumeCommand{ apiType: helmChartType, object: &helmChartAdapter{&sourcev1.HelmChart{}}, + list: &helmChartListAdapter{&sourcev1.HelmChartList{}}, }.run, } @@ -51,3 +52,7 @@ func (obj helmChartAdapter) setUnsuspended() { func (obj helmChartAdapter) successMessage() string { return fmt.Sprintf("fetched revision %s", obj.Status.Artifact.Revision) } + +func (a helmChartListAdapter) resumeItem(i int) resumable { + return &helmChartAdapter{&a.HelmChartList.Items[i]} +} diff --git a/cmd/flux/resume_source_git.go b/cmd/flux/resume_source_git.go index e67614d60bb6dc205e9db369109f7f96fb12f7ee..f4aa22edad77d0f4829f85461730318814352279 100644 --- a/cmd/flux/resume_source_git.go +++ b/cmd/flux/resume_source_git.go @@ -31,6 +31,7 @@ var resumeSourceGitCmd = &cobra.Command{ RunE: resumeCommand{ apiType: gitRepositoryType, object: gitRepositoryAdapter{&sourcev1.GitRepository{}}, + list: gitRepositoryListAdapter{&sourcev1.GitRepositoryList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj gitRepositoryAdapter) getObservedGeneration() int64 { func (obj gitRepositoryAdapter) setUnsuspended() { obj.GitRepository.Spec.Suspend = false } + +func (a gitRepositoryListAdapter) resumeItem(i int) resumable { + return &gitRepositoryAdapter{&a.GitRepositoryList.Items[i]} +} diff --git a/cmd/flux/resume_source_helm.go b/cmd/flux/resume_source_helm.go index 1a9a10b64885ccd29c9766c008914e282f9b5026..a22d73270af21d09eebe40f00a2a306d8f6a85de 100644 --- a/cmd/flux/resume_source_helm.go +++ b/cmd/flux/resume_source_helm.go @@ -31,6 +31,7 @@ var resumeSourceHelmCmd = &cobra.Command{ RunE: resumeCommand{ apiType: helmRepositoryType, object: helmRepositoryAdapter{&sourcev1.HelmRepository{}}, + list: helmRepositoryListAdapter{&sourcev1.HelmRepositoryList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj helmRepositoryAdapter) getObservedGeneration() int64 { func (obj helmRepositoryAdapter) setUnsuspended() { obj.HelmRepository.Spec.Suspend = false } + +func (a helmRepositoryListAdapter) resumeItem(i int) resumable { + return &helmRepositoryAdapter{&a.HelmRepositoryList.Items[i]} +} diff --git a/cmd/flux/suspend.go b/cmd/flux/suspend.go index 6f2eac884a96c48067be7ba8d066f1908293a768..101f29bb71ea25d7b65c45819fec0fadb31cf6ca 100644 --- a/cmd/flux/suspend.go +++ b/cmd/flux/suspend.go @@ -21,7 +21,7 @@ import ( "fmt" "github.com/spf13/cobra" - "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" "github.com/fluxcd/flux2/internal/utils" ) @@ -32,7 +32,15 @@ var suspendCmd = &cobra.Command{ Long: "The suspend sub-commands suspend the reconciliation of a resource.", } +type SuspendFlags struct { + all bool +} + +var suspendArgs SuspendFlags + func init() { + suspendCmd.PersistentFlags().BoolVarP(&suspendArgs.all, "all", "", false, + "suspend all resources in that namespace") rootCmd.AddCommand(suspendCmd) } @@ -44,14 +52,19 @@ type suspendable interface { type suspendCommand struct { apiType + list listSuspendable object suspendable } +type listSuspendable interface { + listAdapter + item(i int) suspendable +} + func (suspend suspendCommand) run(cmd *cobra.Command, args []string) error { - if len(args) < 1 { + if len(args) < 1 && !suspendArgs.all { return fmt.Errorf("%s name is required", suspend.humanKind) } - name := args[0] ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout) defer cancel() @@ -61,21 +74,33 @@ func (suspend suspendCommand) run(cmd *cobra.Command, args []string) error { return err } - namespacedName := types.NamespacedName{ - Namespace: rootArgs.namespace, - Name: name, + var listOpts []client.ListOption + listOpts = append(listOpts, client.InNamespace(rootArgs.namespace)) + if len(args) > 0 { + listOpts = append(listOpts, client.MatchingFields{ + "metadata.name": args[0], + }) } - err = kubeClient.Get(ctx, namespacedName, suspend.object.asClientObject()) + + err = kubeClient.List(ctx, suspend.list.asClientList(), listOpts...) if err != nil { return err } - logger.Actionf("suspending %s %s in %s namespace", suspend.humanKind, name, rootArgs.namespace) - suspend.object.setSuspended() - if err := kubeClient.Update(ctx, suspend.object.asClientObject()); err != nil { - return err + if suspend.list.len() == 0 { + logger.Failuref("no %s objects found in %s namespace", suspend.kind, rootArgs.namespace) + return nil + } + + for i := 0; i < suspend.list.len(); i++ { + logger.Actionf("suspending %s %s in %s namespace", suspend.humanKind, suspend.list.item(i).asClientObject().GetName(), rootArgs.namespace) + suspend.list.item(i).setSuspended() + if err := kubeClient.Update(ctx, suspend.list.item(i).asClientObject()); err != nil { + return err + } + logger.Successf("%s suspended", suspend.humanKind) + } - logger.Successf("%s suspended", suspend.humanKind) return nil } diff --git a/cmd/flux/suspend_alert.go b/cmd/flux/suspend_alert.go index f963bb882c2081ea36f2d1e6eeb318cbe9b16a5a..eb3c184f8b4d61d76f7de71228ded7885bd1aa0d 100644 --- a/cmd/flux/suspend_alert.go +++ b/cmd/flux/suspend_alert.go @@ -31,6 +31,7 @@ var suspendAlertCmd = &cobra.Command{ RunE: suspendCommand{ apiType: alertType, object: &alertAdapter{¬ificationv1.Alert{}}, + list: &alertListAdapter{¬ificationv1.AlertList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj alertAdapter) isSuspended() bool { func (obj alertAdapter) setSuspended() { obj.Alert.Spec.Suspend = true } + +func (a alertListAdapter) item(i int) suspendable { + return &alertAdapter{&a.AlertList.Items[i]} +} diff --git a/cmd/flux/suspend_helmrelease.go b/cmd/flux/suspend_helmrelease.go index 11f88b8280112c7457ad36d74c2b2382d1accc2e..d222916a02d8b39b9a3fb4651ea57457b072b5ba 100644 --- a/cmd/flux/suspend_helmrelease.go +++ b/cmd/flux/suspend_helmrelease.go @@ -32,6 +32,7 @@ var suspendHrCmd = &cobra.Command{ RunE: suspendCommand{ apiType: helmReleaseType, object: &helmReleaseAdapter{&helmv2.HelmRelease{}}, + list: &helmReleaseListAdapter{&helmv2.HelmReleaseList{}}, }.run, } @@ -46,3 +47,7 @@ func (obj helmReleaseAdapter) isSuspended() bool { func (obj helmReleaseAdapter) setSuspended() { obj.HelmRelease.Spec.Suspend = true } + +func (a helmReleaseListAdapter) item(i int) suspendable { + return &helmReleaseAdapter{&a.HelmReleaseList.Items[i]} +} diff --git a/cmd/flux/suspend_image_repository.go b/cmd/flux/suspend_image_repository.go index 6ea3f45f7f87d0a1d493e529500e47c8f9bda5cb..768299e82e79db98628743b71d157f74b1a8f98b 100644 --- a/cmd/flux/suspend_image_repository.go +++ b/cmd/flux/suspend_image_repository.go @@ -31,6 +31,7 @@ var suspendImageRepositoryCmd = &cobra.Command{ RunE: suspendCommand{ apiType: imageRepositoryType, object: imageRepositoryAdapter{&imagev1.ImageRepository{}}, + list: &imageRepositoryListAdapter{&imagev1.ImageRepositoryList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj imageRepositoryAdapter) isSuspended() bool { func (obj imageRepositoryAdapter) setSuspended() { obj.ImageRepository.Spec.Suspend = true } + +func (a imageRepositoryListAdapter) item(i int) suspendable { + return &imageRepositoryAdapter{&a.ImageRepositoryList.Items[i]} +} diff --git a/cmd/flux/suspend_image_updateauto.go b/cmd/flux/suspend_image_updateauto.go index c8bd8acaa3e0b31a7d867fb1833fadc60f9115db..3d4f81b42366f40f6a469ac08ec8589d9575d3c3 100644 --- a/cmd/flux/suspend_image_updateauto.go +++ b/cmd/flux/suspend_image_updateauto.go @@ -31,6 +31,7 @@ var suspendImageUpdateCmd = &cobra.Command{ RunE: suspendCommand{ apiType: imageUpdateAutomationType, object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}}, + list: &imageUpdateAutomationListAdapter{&autov1.ImageUpdateAutomationList{}}, }.run, } @@ -45,3 +46,7 @@ func (update imageUpdateAutomationAdapter) isSuspended() bool { func (update imageUpdateAutomationAdapter) setSuspended() { update.ImageUpdateAutomation.Spec.Suspend = true } + +func (a imageUpdateAutomationListAdapter) item(i int) suspendable { + return &imageUpdateAutomationAdapter{&a.ImageUpdateAutomationList.Items[i]} +} diff --git a/cmd/flux/suspend_kustomization.go b/cmd/flux/suspend_kustomization.go index 272c5d6558cd1147d6c3e1b6512f18a1cc0c3e0a..1d1f208b1cb4ee9b2fe69d1f531fd4b0f5ec41af 100644 --- a/cmd/flux/suspend_kustomization.go +++ b/cmd/flux/suspend_kustomization.go @@ -32,6 +32,7 @@ var suspendKsCmd = &cobra.Command{ RunE: suspendCommand{ apiType: kustomizationType, object: kustomizationAdapter{&kustomizev1.Kustomization{}}, + list: &kustomizationListAdapter{&kustomizev1.KustomizationList{}}, }.run, } @@ -46,3 +47,7 @@ func (obj kustomizationAdapter) isSuspended() bool { func (obj kustomizationAdapter) setSuspended() { obj.Kustomization.Spec.Suspend = true } + +func (a kustomizationListAdapter) item(i int) suspendable { + return &kustomizationAdapter{&a.KustomizationList.Items[i]} +} diff --git a/cmd/flux/suspend_receiver.go b/cmd/flux/suspend_receiver.go index 7223fd495d92fc1f7e20804332f94858f878707b..90ca5cf0961d63fea997a4c28176fcbacf371f05 100644 --- a/cmd/flux/suspend_receiver.go +++ b/cmd/flux/suspend_receiver.go @@ -31,6 +31,7 @@ var suspendReceiverCmd = &cobra.Command{ RunE: suspendCommand{ apiType: receiverType, object: &receiverAdapter{¬ificationv1.Receiver{}}, + list: &receiverListAdapter{¬ificationv1.ReceiverList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj receiverAdapter) isSuspended() bool { func (obj receiverAdapter) setSuspended() { obj.Receiver.Spec.Suspend = true } + +func (a receiverListAdapter) item(i int) suspendable { + return &receiverAdapter{&a.ReceiverList.Items[i]} +} diff --git a/cmd/flux/suspend_source_bucket.go b/cmd/flux/suspend_source_bucket.go index 523d41a831d5bcb9adf72f025a546d53f587c0ab..72f1d0e3f4f63315db0a59fd8b54e4bbbd7aa8b2 100644 --- a/cmd/flux/suspend_source_bucket.go +++ b/cmd/flux/suspend_source_bucket.go @@ -31,6 +31,7 @@ var suspendSourceBucketCmd = &cobra.Command{ RunE: suspendCommand{ apiType: bucketType, object: bucketAdapter{&sourcev1.Bucket{}}, + list: bucketListAdapter{&sourcev1.BucketList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj bucketAdapter) isSuspended() bool { func (obj bucketAdapter) setSuspended() { obj.Bucket.Spec.Suspend = true } + +func (a bucketListAdapter) item(i int) suspendable { + return &bucketAdapter{&a.BucketList.Items[i]} +} diff --git a/cmd/flux/suspend_source_chart.go b/cmd/flux/suspend_source_chart.go index 8741a032698ec55274c1ecb7b5746577facc55cf..703e820e367cc9f417538e34968fc9b6eb62ed1d 100644 --- a/cmd/flux/suspend_source_chart.go +++ b/cmd/flux/suspend_source_chart.go @@ -31,6 +31,7 @@ var suspendSourceHelmChartCmd = &cobra.Command{ RunE: suspendCommand{ apiType: helmChartType, object: helmChartAdapter{&sourcev1.HelmChart{}}, + list: helmChartListAdapter{&sourcev1.HelmChartList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj helmChartAdapter) isSuspended() bool { func (obj helmChartAdapter) setSuspended() { obj.HelmChart.Spec.Suspend = true } + +func (a helmChartListAdapter) item(i int) suspendable { + return &helmChartAdapter{&a.HelmChartList.Items[i]} +} diff --git a/cmd/flux/suspend_source_git.go b/cmd/flux/suspend_source_git.go index 9cc08fa2df14d794e970278085d42fe79c39c61e..bc058303ea40ea91d8dbe8615ad3ca02335a7fc9 100644 --- a/cmd/flux/suspend_source_git.go +++ b/cmd/flux/suspend_source_git.go @@ -31,6 +31,7 @@ var suspendSourceGitCmd = &cobra.Command{ RunE: suspendCommand{ apiType: gitRepositoryType, object: gitRepositoryAdapter{&sourcev1.GitRepository{}}, + list: gitRepositoryListAdapter{&sourcev1.GitRepositoryList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj gitRepositoryAdapter) isSuspended() bool { func (obj gitRepositoryAdapter) setSuspended() { obj.GitRepository.Spec.Suspend = true } + +func (a gitRepositoryListAdapter) item(i int) suspendable { + return &gitRepositoryAdapter{&a.GitRepositoryList.Items[i]} +} diff --git a/cmd/flux/suspend_source_helm.go b/cmd/flux/suspend_source_helm.go index 5cd483f646a96dd8036448f458d38db08d42f3fb..a4a5787c9678d40c888ea453357526b77a6cac59 100644 --- a/cmd/flux/suspend_source_helm.go +++ b/cmd/flux/suspend_source_helm.go @@ -31,6 +31,7 @@ var suspendSourceHelmCmd = &cobra.Command{ RunE: suspendCommand{ apiType: helmRepositoryType, object: helmRepositoryAdapter{&sourcev1.HelmRepository{}}, + list: helmRepositoryListAdapter{&sourcev1.HelmRepositoryList{}}, }.run, } @@ -45,3 +46,7 @@ func (obj helmRepositoryAdapter) isSuspended() bool { func (obj helmRepositoryAdapter) setSuspended() { obj.HelmRepository.Spec.Suspend = true } + +func (a helmRepositoryListAdapter) item(i int) suspendable { + return &helmRepositoryAdapter{&a.HelmRepositoryList.Items[i]} +} diff --git a/docs/cmd/flux_resume.md b/docs/cmd/flux_resume.md index afeea5395ec90a7a40da30c63a99e49a40284dd5..7a5fe604a39dee3ddfa6f7ccea11858222032aa8 100644 --- a/docs/cmd/flux_resume.md +++ b/docs/cmd/flux_resume.md @@ -12,6 +12,7 @@ The resume sub-commands resume a suspended resource. ### Options ``` + --all suspend all resources in that namespace -h, --help help for resume ``` diff --git a/docs/cmd/flux_resume_alert.md b/docs/cmd/flux_resume_alert.md index cd8cc060958d4451cdc62e1fae6d5432e3b82926..a60af6a2829b69516c05cb4fd1cc5791c29660ff 100644 --- a/docs/cmd/flux_resume_alert.md +++ b/docs/cmd/flux_resume_alert.md @@ -30,6 +30,7 @@ flux resume alert [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_helmrelease.md b/docs/cmd/flux_resume_helmrelease.md index 5d4f26ffbe43d81c7a15bd8809658aa7c194e323..a7befe762835090528ae70dc0cc31bbbd38c2cd4 100644 --- a/docs/cmd/flux_resume_helmrelease.md +++ b/docs/cmd/flux_resume_helmrelease.md @@ -30,6 +30,7 @@ flux resume helmrelease [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_image.md b/docs/cmd/flux_resume_image.md index 7a43a2a4c81ec99ec24b37ee44439bb954e91f99..754042dd87dbd4daa7a278d281ab542ba9671686 100644 --- a/docs/cmd/flux_resume_image.md +++ b/docs/cmd/flux_resume_image.md @@ -18,6 +18,7 @@ The resume image sub-commands resume suspended image automation objects. ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_image_repository.md b/docs/cmd/flux_resume_image_repository.md index 4649de8db52d8c636c298ed39d87b56ad37e06bf..0217c465c9f0d8410389080f8e8ef7dc11141304 100644 --- a/docs/cmd/flux_resume_image_repository.md +++ b/docs/cmd/flux_resume_image_repository.md @@ -29,6 +29,7 @@ flux resume image repository [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_image_update.md b/docs/cmd/flux_resume_image_update.md index 3ec77ab2f5de6c6232bc9bfd2a2be86848567456..29d4a36f73b0be8c0467bc8886a5431cb10caf81 100644 --- a/docs/cmd/flux_resume_image_update.md +++ b/docs/cmd/flux_resume_image_update.md @@ -29,6 +29,7 @@ flux resume image update [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_kustomization.md b/docs/cmd/flux_resume_kustomization.md index 5d6a6bdc75890a2f16f6aa60b57cc45ed62a9f67..9322c870d0232087949850567685d859d47958bd 100644 --- a/docs/cmd/flux_resume_kustomization.md +++ b/docs/cmd/flux_resume_kustomization.md @@ -30,6 +30,7 @@ flux resume kustomization [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_receiver.md b/docs/cmd/flux_resume_receiver.md index 7f598b6814ef52fc5d544f116612cee00a144f67..c44875830e4d8cc60cfffc15c91510383d2fbd14 100644 --- a/docs/cmd/flux_resume_receiver.md +++ b/docs/cmd/flux_resume_receiver.md @@ -30,6 +30,7 @@ flux resume receiver [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_source.md b/docs/cmd/flux_resume_source.md index 3e2257e3389cfc5fa2e6948007b2e8aeecf0d3ff..2ccde0b3363bc7694be38e6cac5731ebe62be5e7 100644 --- a/docs/cmd/flux_resume_source.md +++ b/docs/cmd/flux_resume_source.md @@ -18,6 +18,7 @@ The resume sub-commands resume a suspended source. ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_source_bucket.md b/docs/cmd/flux_resume_source_bucket.md index c9fd6eb87ce47b60f304ed7bef5481853f3f6afb..2ce39e0a697f25c2f980d67770103eb19b119a3c 100644 --- a/docs/cmd/flux_resume_source_bucket.md +++ b/docs/cmd/flux_resume_source_bucket.md @@ -29,6 +29,7 @@ flux resume source bucket [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_source_chart.md b/docs/cmd/flux_resume_source_chart.md index ef68931aeca265aafd811b66bee24c3692d6e69b..f356329fc6c63b40e963b790ee078294203c81d2 100644 --- a/docs/cmd/flux_resume_source_chart.md +++ b/docs/cmd/flux_resume_source_chart.md @@ -29,6 +29,7 @@ flux resume source chart [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_source_git.md b/docs/cmd/flux_resume_source_git.md index 1e32e35e32976809f762546392e304edafb6d108..bf02fbb5248e886ee8713f14a2ada5dfeb629eb5 100644 --- a/docs/cmd/flux_resume_source_git.md +++ b/docs/cmd/flux_resume_source_git.md @@ -29,6 +29,7 @@ flux resume source git [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_resume_source_helm.md b/docs/cmd/flux_resume_source_helm.md index cc7292af2352ffb4c1d82293a4e3d0a12fcc4eb9..23c404d8cdc788a0bd53bb4b8a74b4b9a096a5c6 100644 --- a/docs/cmd/flux_resume_source_helm.md +++ b/docs/cmd/flux_resume_source_helm.md @@ -29,6 +29,7 @@ flux resume source helm [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend.md b/docs/cmd/flux_suspend.md index 56eb8be4d5095c471b79b0be27b13993186237dc..8d2da1d53037a19ecf9ec0d978de50b3de854db1 100644 --- a/docs/cmd/flux_suspend.md +++ b/docs/cmd/flux_suspend.md @@ -12,6 +12,7 @@ The suspend sub-commands suspend the reconciliation of a resource. ### Options ``` + --all suspend all resources in that namespace -h, --help help for suspend ``` diff --git a/docs/cmd/flux_suspend_alert.md b/docs/cmd/flux_suspend_alert.md index e1ba99f2293d07609aefdeaaa6bc27f3b86ff3d6..3e55db73d2ff37a329955ae1f737eaa2fd2297b0 100644 --- a/docs/cmd/flux_suspend_alert.md +++ b/docs/cmd/flux_suspend_alert.md @@ -29,6 +29,7 @@ flux suspend alert [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_helmrelease.md b/docs/cmd/flux_suspend_helmrelease.md index b55d335fb24a7aae60c9ac5f440b2a4b461f36cd..37a41e4ad655f85da81d902f1c6bec25d4ba62d3 100644 --- a/docs/cmd/flux_suspend_helmrelease.md +++ b/docs/cmd/flux_suspend_helmrelease.md @@ -29,6 +29,7 @@ flux suspend helmrelease [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_image.md b/docs/cmd/flux_suspend_image.md index 9a2659e2a3e7fafe904da3c81059252587662300..603c98ef0926e2a5700d15cad71a335660a22390 100644 --- a/docs/cmd/flux_suspend_image.md +++ b/docs/cmd/flux_suspend_image.md @@ -18,6 +18,7 @@ The suspend image sub-commands suspend the reconciliation of an image automation ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_image_repository.md b/docs/cmd/flux_suspend_image_repository.md index 153c8a01ade62fc543fd365ee98f8297ead3ba1d..34b82f76bcbe382a0c6b818a3f9ba9e8da60377f 100644 --- a/docs/cmd/flux_suspend_image_repository.md +++ b/docs/cmd/flux_suspend_image_repository.md @@ -29,6 +29,7 @@ flux suspend image repository [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_image_update.md b/docs/cmd/flux_suspend_image_update.md index 5970f77a49455349c49f9a6fb55f32a492176bd9..7d0f0d801e4d7a1f2ade68af30f53f7d26aeee99 100644 --- a/docs/cmd/flux_suspend_image_update.md +++ b/docs/cmd/flux_suspend_image_update.md @@ -29,6 +29,7 @@ flux suspend image update [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_kustomization.md b/docs/cmd/flux_suspend_kustomization.md index edfbb530cc1733bd52e2563546165dc840831669..394fdc19ae919e5fe590d9b92a00faa7196a99e1 100644 --- a/docs/cmd/flux_suspend_kustomization.md +++ b/docs/cmd/flux_suspend_kustomization.md @@ -29,6 +29,7 @@ flux suspend kustomization [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_receiver.md b/docs/cmd/flux_suspend_receiver.md index bc9bb259c8c7e1b428629f7ac7c17f8f023fc122..aebfc33eadccba05065114deed42165257fed4ad 100644 --- a/docs/cmd/flux_suspend_receiver.md +++ b/docs/cmd/flux_suspend_receiver.md @@ -29,6 +29,7 @@ flux suspend receiver [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_source.md b/docs/cmd/flux_suspend_source.md index 87150e975697f02ba5a705420129569e985fcf7f..123dc0e9ddc9f304712bd83ca30d0f5fbeab07c2 100644 --- a/docs/cmd/flux_suspend_source.md +++ b/docs/cmd/flux_suspend_source.md @@ -18,6 +18,7 @@ The suspend sub-commands suspend the reconciliation of a source. ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_source_bucket.md b/docs/cmd/flux_suspend_source_bucket.md index ca41385f86fb9af245e234b5e7088f87d1b525c1..3d83c432dbdc118c7a6d34d6c39e4505a10305e6 100644 --- a/docs/cmd/flux_suspend_source_bucket.md +++ b/docs/cmd/flux_suspend_source_bucket.md @@ -29,6 +29,7 @@ flux suspend source bucket [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_source_chart.md b/docs/cmd/flux_suspend_source_chart.md index aa3c10783fded14a8eb8ef246b9a14b3d2637078..857fad99bbbca12df11d8a9804ffe79ccb6d0749 100644 --- a/docs/cmd/flux_suspend_source_chart.md +++ b/docs/cmd/flux_suspend_source_chart.md @@ -29,6 +29,7 @@ flux suspend source chart [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_source_git.md b/docs/cmd/flux_suspend_source_git.md index 50c372f17c2932c5742415ae94c2110c336f9137..865affc3d715aeb86f21fad87134e9c05e9dbbd4 100644 --- a/docs/cmd/flux_suspend_source_git.md +++ b/docs/cmd/flux_suspend_source_git.md @@ -29,6 +29,7 @@ flux suspend source git [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system") diff --git a/docs/cmd/flux_suspend_source_helm.md b/docs/cmd/flux_suspend_source_helm.md index 1c8003cf0a91e9e629363644bb9621bceb1311f7..acee9f15c83cd60d2026ba49750f6e3f0a879737 100644 --- a/docs/cmd/flux_suspend_source_helm.md +++ b/docs/cmd/flux_suspend_source_helm.md @@ -29,6 +29,7 @@ flux suspend source helm [name] [flags] ### Options inherited from parent commands ``` + --all suspend all resources in that namespace --context string kubernetes context to use --kubeconfig string absolute path to the kubeconfig file -n, --namespace string the namespace scope for this operation (default "flux-system")