From 479fc3cd3b9813982add4e70d65bda312698a0fd Mon Sep 17 00:00:00 2001 From: Travis Mattera Date: Mon, 11 Sep 2023 19:53:34 -0700 Subject: [PATCH 1/6] Adds an optional `reason` cli flag to the `suspend` command that accepts a reason for why the resource was suspended. Defines the resource metadata annotation key that stores the reason for the resource suspension. Updates the suspend and resume resource patching to add or remove the annotation holding the suspend reason. Signed-off-by: Travis Mattera --- cmd/flux/resume_alert.go | 3 +++ cmd/flux/resume_helmrelease.go | 3 +++ cmd/flux/resume_image_repository.go | 3 +++ cmd/flux/resume_image_updateauto.go | 3 +++ cmd/flux/resume_kustomization.go | 3 +++ cmd/flux/resume_receiver.go | 3 +++ cmd/flux/resume_source_bucket.go | 3 +++ cmd/flux/resume_source_chart.go | 3 +++ cmd/flux/resume_source_git.go | 3 +++ cmd/flux/resume_source_helm.go | 3 +++ cmd/flux/resume_source_oci.go | 3 +++ cmd/flux/suspend.go | 14 +++++++++++--- cmd/flux/suspend_alert.go | 3 ++- cmd/flux/suspend_helmrelease.go | 3 ++- cmd/flux/suspend_image_repository.go | 3 ++- cmd/flux/suspend_image_updateauto.go | 3 ++- cmd/flux/suspend_kustomization.go | 3 ++- cmd/flux/suspend_receiver.go | 3 ++- cmd/flux/suspend_source_bucket.go | 3 ++- cmd/flux/suspend_source_chart.go | 3 ++- cmd/flux/suspend_source_git.go | 3 ++- cmd/flux/suspend_source_helm.go | 3 ++- cmd/flux/suspend_source_oci.go | 3 ++- 23 files changed, 66 insertions(+), 14 deletions(-) diff --git a/cmd/flux/resume_alert.go b/cmd/flux/resume_alert.go index 713aebb38a..7ed2922166 100644 --- a/cmd/flux/resume_alert.go +++ b/cmd/flux/resume_alert.go @@ -49,6 +49,9 @@ func (obj alertAdapter) getObservedGeneration() int64 { func (obj alertAdapter) setUnsuspended() { obj.Alert.Spec.Suspend = false + if _, ok := obj.Alert.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.Alert.Annotations, SuspendReasonAnnotation) + } } func (obj alertAdapter) successMessage() string { diff --git a/cmd/flux/resume_helmrelease.go b/cmd/flux/resume_helmrelease.go index b058d273b4..6acbd2b3e0 100644 --- a/cmd/flux/resume_helmrelease.go +++ b/cmd/flux/resume_helmrelease.go @@ -52,6 +52,9 @@ func (obj helmReleaseAdapter) getObservedGeneration() int64 { func (obj helmReleaseAdapter) setUnsuspended() { obj.HelmRelease.Spec.Suspend = false + if _, ok := obj.HelmRelease.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.HelmRelease.Annotations, SuspendReasonAnnotation) + } } func (obj helmReleaseAdapter) successMessage() string { diff --git a/cmd/flux/resume_image_repository.go b/cmd/flux/resume_image_repository.go index a9ab36cd12..b1e493642a 100644 --- a/cmd/flux/resume_image_repository.go +++ b/cmd/flux/resume_image_repository.go @@ -48,6 +48,9 @@ func (obj imageRepositoryAdapter) getObservedGeneration() int64 { func (obj imageRepositoryAdapter) setUnsuspended() { obj.ImageRepository.Spec.Suspend = false + if _, ok := obj.ImageRepository.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.ImageRepository.Annotations, SuspendReasonAnnotation) + } } func (a imageRepositoryListAdapter) resumeItem(i int) resumable { diff --git a/cmd/flux/resume_image_updateauto.go b/cmd/flux/resume_image_updateauto.go index d50fddf787..d0131c988c 100644 --- a/cmd/flux/resume_image_updateauto.go +++ b/cmd/flux/resume_image_updateauto.go @@ -44,6 +44,9 @@ func init() { func (obj imageUpdateAutomationAdapter) setUnsuspended() { obj.ImageUpdateAutomation.Spec.Suspend = false + if _, ok := obj.ImageUpdateAutomation.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.ImageUpdateAutomation.Annotations, SuspendReasonAnnotation) + } } func (obj imageUpdateAutomationAdapter) getObservedGeneration() int64 { diff --git a/cmd/flux/resume_kustomization.go b/cmd/flux/resume_kustomization.go index a03aed6258..ab8ed7dc21 100644 --- a/cmd/flux/resume_kustomization.go +++ b/cmd/flux/resume_kustomization.go @@ -52,6 +52,9 @@ func (obj kustomizationAdapter) getObservedGeneration() int64 { func (obj kustomizationAdapter) setUnsuspended() { obj.Kustomization.Spec.Suspend = false + if _, ok := obj.Kustomization.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.Kustomization.Annotations, SuspendReasonAnnotation) + } } func (obj kustomizationAdapter) successMessage() string { diff --git a/cmd/flux/resume_receiver.go b/cmd/flux/resume_receiver.go index c99bd755b9..1659c6bf27 100644 --- a/cmd/flux/resume_receiver.go +++ b/cmd/flux/resume_receiver.go @@ -49,6 +49,9 @@ func (obj receiverAdapter) getObservedGeneration() int64 { func (obj receiverAdapter) setUnsuspended() { obj.Receiver.Spec.Suspend = false + if _, ok := obj.Receiver.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.Receiver.Annotations, SuspendReasonAnnotation) + } } func (obj receiverAdapter) successMessage() string { diff --git a/cmd/flux/resume_source_bucket.go b/cmd/flux/resume_source_bucket.go index ea1fe37d97..de0ec2b652 100644 --- a/cmd/flux/resume_source_bucket.go +++ b/cmd/flux/resume_source_bucket.go @@ -48,6 +48,9 @@ func (obj bucketAdapter) getObservedGeneration() int64 { func (obj bucketAdapter) setUnsuspended() { obj.Bucket.Spec.Suspend = false + if _, ok := obj.Bucket.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.Bucket.Annotations, SuspendReasonAnnotation) + } } func (a bucketListAdapter) resumeItem(i int) resumable { diff --git a/cmd/flux/resume_source_chart.go b/cmd/flux/resume_source_chart.go index 6322f06fc1..beb3ed974e 100644 --- a/cmd/flux/resume_source_chart.go +++ b/cmd/flux/resume_source_chart.go @@ -50,6 +50,9 @@ func (obj helmChartAdapter) getObservedGeneration() int64 { func (obj helmChartAdapter) setUnsuspended() { obj.HelmChart.Spec.Suspend = false + if _, ok := obj.HelmChart.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.HelmChart.Annotations, SuspendReasonAnnotation) + } } func (obj helmChartAdapter) successMessage() string { diff --git a/cmd/flux/resume_source_git.go b/cmd/flux/resume_source_git.go index 751714a418..23289870d1 100644 --- a/cmd/flux/resume_source_git.go +++ b/cmd/flux/resume_source_git.go @@ -48,6 +48,9 @@ func (obj gitRepositoryAdapter) getObservedGeneration() int64 { func (obj gitRepositoryAdapter) setUnsuspended() { obj.GitRepository.Spec.Suspend = false + if _, ok := obj.GitRepository.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.GitRepository.Annotations, SuspendReasonAnnotation) + } } func (a gitRepositoryListAdapter) resumeItem(i int) resumable { diff --git a/cmd/flux/resume_source_helm.go b/cmd/flux/resume_source_helm.go index 0ac641ebb6..54531cb81d 100644 --- a/cmd/flux/resume_source_helm.go +++ b/cmd/flux/resume_source_helm.go @@ -48,6 +48,9 @@ func (obj helmRepositoryAdapter) getObservedGeneration() int64 { func (obj helmRepositoryAdapter) setUnsuspended() { obj.HelmRepository.Spec.Suspend = false + if _, ok := obj.HelmRepository.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.HelmRepository.Annotations, SuspendReasonAnnotation) + } } func (a helmRepositoryListAdapter) resumeItem(i int) resumable { diff --git a/cmd/flux/resume_source_oci.go b/cmd/flux/resume_source_oci.go index 04b20a4bb5..db40ec0558 100644 --- a/cmd/flux/resume_source_oci.go +++ b/cmd/flux/resume_source_oci.go @@ -48,6 +48,9 @@ func (obj ociRepositoryAdapter) getObservedGeneration() int64 { func (obj ociRepositoryAdapter) setUnsuspended() { obj.OCIRepository.Spec.Suspend = false + if _, ok := obj.OCIRepository.Annotations[SuspendReasonAnnotation]; ok { + delete(obj.OCIRepository.Annotations, SuspendReasonAnnotation) + } } func (a ociRepositoryListAdapter) resumeItem(i int) resumable { diff --git a/cmd/flux/suspend.go b/cmd/flux/suspend.go index e0023c7e62..2ac84f9459 100644 --- a/cmd/flux/suspend.go +++ b/cmd/flux/suspend.go @@ -34,7 +34,8 @@ var suspendCmd = &cobra.Command{ } type SuspendFlags struct { - all bool + all bool + reason string } var suspendArgs SuspendFlags @@ -42,6 +43,8 @@ var suspendArgs SuspendFlags func init() { suspendCmd.PersistentFlags().BoolVarP(&suspendArgs.all, "all", "", false, "suspend all resources in that namespace") + suspendCmd.PersistentFlags().StringVarP(&suspendArgs.reason, "reason", "r", "suspended", + "set a reason for why the resource is suspended") rootCmd.AddCommand(suspendCmd) } @@ -49,7 +52,7 @@ type suspendable interface { adapter copyable isSuspended() bool - setSuspended() + setSuspended(reason string) } type suspendCommand struct { @@ -76,6 +79,7 @@ func (suspend suspendCommand) run(cmd *cobra.Command, args []string) error { return err } + // in case of all, get all in namespace and patch 'em if len(args) < 1 && suspendArgs.all { listOpts := []client.ListOption{ client.InNamespace(*kubeconfigArgs.Namespace), @@ -88,6 +92,7 @@ func (suspend suspendCommand) run(cmd *cobra.Command, args []string) error { return nil } + // when not all, patch list of args processed := make(map[string]struct{}, len(args)) for _, arg := range args { if _, has := processed[arg]; has { @@ -130,7 +135,7 @@ func (suspend suspendCommand) patch(ctx context.Context, kubeClient client.WithW obj := suspend.list.item(i) patch := client.MergeFrom(obj.deepCopyClientObject()) - obj.setSuspended() + obj.setSuspended(suspendArgs.reason) if err := kubeClient.Patch(ctx, obj.asClientObject(), patch); err != nil { return err } @@ -140,3 +145,6 @@ func (suspend suspendCommand) patch(ctx context.Context, kubeClient client.WithW return nil } + +// SuspendReasonAnnotation is the metadata key used to store the reason for resource suspension +const SuspendReasonAnnotation string = "suspend.fluxcd.io/reason" diff --git a/cmd/flux/suspend_alert.go b/cmd/flux/suspend_alert.go index 17cdd80187..872627652e 100644 --- a/cmd/flux/suspend_alert.go +++ b/cmd/flux/suspend_alert.go @@ -47,8 +47,9 @@ func (obj alertAdapter) isSuspended() bool { return obj.Alert.Spec.Suspend } -func (obj alertAdapter) setSuspended() { +func (obj alertAdapter) setSuspended(reason string) { obj.Alert.Spec.Suspend = true + obj.Alert.Annotations[SuspendReasonAnnotation] = reason } func (a alertListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_helmrelease.go b/cmd/flux/suspend_helmrelease.go index 5872c8b464..88d78742f3 100644 --- a/cmd/flux/suspend_helmrelease.go +++ b/cmd/flux/suspend_helmrelease.go @@ -48,8 +48,9 @@ func (obj helmReleaseAdapter) isSuspended() bool { return obj.HelmRelease.Spec.Suspend } -func (obj helmReleaseAdapter) setSuspended() { +func (obj helmReleaseAdapter) setSuspended(reason string) { obj.HelmRelease.Spec.Suspend = true + obj.HelmRelease.Annotations[SuspendReasonAnnotation] = reason } func (a helmReleaseListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_image_repository.go b/cmd/flux/suspend_image_repository.go index c6e562d12d..3b9f901c7c 100644 --- a/cmd/flux/suspend_image_repository.go +++ b/cmd/flux/suspend_image_repository.go @@ -47,8 +47,9 @@ func (obj imageRepositoryAdapter) isSuspended() bool { return obj.ImageRepository.Spec.Suspend } -func (obj imageRepositoryAdapter) setSuspended() { +func (obj imageRepositoryAdapter) setSuspended(reason string) { obj.ImageRepository.Spec.Suspend = true + obj.ImageRepository.Annotations[SuspendReasonAnnotation] = reason } func (a imageRepositoryListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_image_updateauto.go b/cmd/flux/suspend_image_updateauto.go index 1c8f11ef6c..5649fa4ed3 100644 --- a/cmd/flux/suspend_image_updateauto.go +++ b/cmd/flux/suspend_image_updateauto.go @@ -47,8 +47,9 @@ func (update imageUpdateAutomationAdapter) isSuspended() bool { return update.ImageUpdateAutomation.Spec.Suspend } -func (update imageUpdateAutomationAdapter) setSuspended() { +func (update imageUpdateAutomationAdapter) setSuspended(reason string) { update.ImageUpdateAutomation.Spec.Suspend = true + update.ImageUpdateAutomation.Annotations[SuspendReasonAnnotation] = reason } func (a imageUpdateAutomationListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_kustomization.go b/cmd/flux/suspend_kustomization.go index ac6c72e14d..7689c90450 100644 --- a/cmd/flux/suspend_kustomization.go +++ b/cmd/flux/suspend_kustomization.go @@ -48,8 +48,9 @@ func (obj kustomizationAdapter) isSuspended() bool { return obj.Kustomization.Spec.Suspend } -func (obj kustomizationAdapter) setSuspended() { +func (obj kustomizationAdapter) setSuspended(reason string) { obj.Kustomization.Spec.Suspend = true + obj.Kustomization.Annotations[SuspendReasonAnnotation] = reason } func (a kustomizationListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_receiver.go b/cmd/flux/suspend_receiver.go index 7f2e6dd728..b512238bde 100644 --- a/cmd/flux/suspend_receiver.go +++ b/cmd/flux/suspend_receiver.go @@ -47,8 +47,9 @@ func (obj receiverAdapter) isSuspended() bool { return obj.Receiver.Spec.Suspend } -func (obj receiverAdapter) setSuspended() { +func (obj receiverAdapter) setSuspended(reason string) { obj.Receiver.Spec.Suspend = true + obj.Receiver.Annotations[SuspendReasonAnnotation] = reason } func (a receiverListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_source_bucket.go b/cmd/flux/suspend_source_bucket.go index 7fdcfced4a..1a625f3f78 100644 --- a/cmd/flux/suspend_source_bucket.go +++ b/cmd/flux/suspend_source_bucket.go @@ -47,8 +47,9 @@ func (obj bucketAdapter) isSuspended() bool { return obj.Bucket.Spec.Suspend } -func (obj bucketAdapter) setSuspended() { +func (obj bucketAdapter) setSuspended(reason string) { obj.Bucket.Spec.Suspend = true + obj.Bucket.Annotations[SuspendReasonAnnotation] = reason } func (a bucketListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_source_chart.go b/cmd/flux/suspend_source_chart.go index e91327e844..aeccf034f0 100644 --- a/cmd/flux/suspend_source_chart.go +++ b/cmd/flux/suspend_source_chart.go @@ -47,8 +47,9 @@ func (obj helmChartAdapter) isSuspended() bool { return obj.HelmChart.Spec.Suspend } -func (obj helmChartAdapter) setSuspended() { +func (obj helmChartAdapter) setSuspended(reason string) { obj.HelmChart.Spec.Suspend = true + obj.HelmChart.Annotations[SuspendReasonAnnotation] = reason } func (a helmChartListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_source_git.go b/cmd/flux/suspend_source_git.go index 4decf79629..a40cdb05c0 100644 --- a/cmd/flux/suspend_source_git.go +++ b/cmd/flux/suspend_source_git.go @@ -47,8 +47,9 @@ func (obj gitRepositoryAdapter) isSuspended() bool { return obj.GitRepository.Spec.Suspend } -func (obj gitRepositoryAdapter) setSuspended() { +func (obj gitRepositoryAdapter) setSuspended(reason string) { obj.GitRepository.Spec.Suspend = true + obj.GitRepository.Annotations[SuspendReasonAnnotation] = reason } func (a gitRepositoryListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_source_helm.go b/cmd/flux/suspend_source_helm.go index 22598c64cf..6b7a7669bc 100644 --- a/cmd/flux/suspend_source_helm.go +++ b/cmd/flux/suspend_source_helm.go @@ -47,8 +47,9 @@ func (obj helmRepositoryAdapter) isSuspended() bool { return obj.HelmRepository.Spec.Suspend } -func (obj helmRepositoryAdapter) setSuspended() { +func (obj helmRepositoryAdapter) setSuspended(reason string) { obj.HelmRepository.Spec.Suspend = true + obj.HelmRepository.Annotations[SuspendReasonAnnotation] = reason } func (a helmRepositoryListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_source_oci.go b/cmd/flux/suspend_source_oci.go index 3b8e36d6ab..e756b06fc5 100644 --- a/cmd/flux/suspend_source_oci.go +++ b/cmd/flux/suspend_source_oci.go @@ -47,8 +47,9 @@ func (obj ociRepositoryAdapter) isSuspended() bool { return obj.OCIRepository.Spec.Suspend } -func (obj ociRepositoryAdapter) setSuspended() { +func (obj ociRepositoryAdapter) setSuspended(reason string) { obj.OCIRepository.Spec.Suspend = true + obj.OCIRepository.Annotations[SuspendReasonAnnotation] = reason } func (a ociRepositoryListAdapter) item(i int) suspendable { From 46552c56565941af476e3b5ea00684d6f27afa2a Mon Sep 17 00:00:00 2001 From: Travis Mattera Date: Wed, 13 Sep 2023 10:10:43 -0700 Subject: [PATCH 2/6] Update cmd/flux/suspend.go Set annotation key string to suspend.toolkit.fluxcd.io/reason Co-authored-by: Stefan Prodan Signed-off-by: Travis Mattera --- cmd/flux/suspend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/flux/suspend.go b/cmd/flux/suspend.go index 2ac84f9459..e577e7eb47 100644 --- a/cmd/flux/suspend.go +++ b/cmd/flux/suspend.go @@ -147,4 +147,4 @@ func (suspend suspendCommand) patch(ctx context.Context, kubeClient client.WithW } // SuspendReasonAnnotation is the metadata key used to store the reason for resource suspension -const SuspendReasonAnnotation string = "suspend.fluxcd.io/reason" +const SuspendReasonAnnotation string = "suspend.toolkit.fluxcd.io/reason" From 59c759e88593f45a4ff4436b3f5942916e641a8f Mon Sep 17 00:00:00 2001 From: Travis Mattera Date: Wed, 13 Sep 2023 10:12:06 -0700 Subject: [PATCH 3/6] Update cmd/flux/suspend.go Set annotation key string to suspend.toolkit.fluxcd.io/reason Co-authored-by: Stefan Prodan Signed-off-by: Travis Mattera --- cmd/flux/suspend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/flux/suspend.go b/cmd/flux/suspend.go index e577e7eb47..0ab7a91757 100644 --- a/cmd/flux/suspend.go +++ b/cmd/flux/suspend.go @@ -44,7 +44,7 @@ func init() { suspendCmd.PersistentFlags().BoolVarP(&suspendArgs.all, "all", "", false, "suspend all resources in that namespace") suspendCmd.PersistentFlags().StringVarP(&suspendArgs.reason, "reason", "r", "suspended", - "set a reason for why the resource is suspended") + "set a reason for why the resource is suspended, the reason will show up under the suspend.toolkit.fluxcd.io/reason annotation") rootCmd.AddCommand(suspendCmd) } From 0ba9db560bff5f9ee7de240b3b55e57eecf5df6f Mon Sep 17 00:00:00 2001 From: Travis Mattera Date: Wed, 13 Sep 2023 11:00:51 -0700 Subject: [PATCH 4/6] Sets the flux cli `suspend` command `--reason` flag to an empty string as default and changes the flux resource suspend behavior to only apply the suspend reason annotation when a non-empty reason is provided. Signed-off-by: Travis Mattera --- cmd/flux/suspend.go | 2 +- cmd/flux/suspend_alert.go | 4 +++- cmd/flux/suspend_helmrelease.go | 4 +++- cmd/flux/suspend_image_repository.go | 4 +++- cmd/flux/suspend_image_updateauto.go | 4 +++- cmd/flux/suspend_kustomization.go | 4 +++- cmd/flux/suspend_receiver.go | 4 +++- cmd/flux/suspend_source_bucket.go | 4 +++- cmd/flux/suspend_source_chart.go | 4 +++- cmd/flux/suspend_source_git.go | 4 +++- cmd/flux/suspend_source_helm.go | 4 +++- cmd/flux/suspend_source_oci.go | 4 +++- 12 files changed, 34 insertions(+), 12 deletions(-) diff --git a/cmd/flux/suspend.go b/cmd/flux/suspend.go index 0ab7a91757..5ac2ac3795 100644 --- a/cmd/flux/suspend.go +++ b/cmd/flux/suspend.go @@ -43,7 +43,7 @@ var suspendArgs SuspendFlags func init() { suspendCmd.PersistentFlags().BoolVarP(&suspendArgs.all, "all", "", false, "suspend all resources in that namespace") - suspendCmd.PersistentFlags().StringVarP(&suspendArgs.reason, "reason", "r", "suspended", + suspendCmd.PersistentFlags().StringVarP(&suspendArgs.reason, "reason", "r", "", "set a reason for why the resource is suspended, the reason will show up under the suspend.toolkit.fluxcd.io/reason annotation") rootCmd.AddCommand(suspendCmd) } diff --git a/cmd/flux/suspend_alert.go b/cmd/flux/suspend_alert.go index 872627652e..be750c9f9f 100644 --- a/cmd/flux/suspend_alert.go +++ b/cmd/flux/suspend_alert.go @@ -49,7 +49,9 @@ func (obj alertAdapter) isSuspended() bool { func (obj alertAdapter) setSuspended(reason string) { obj.Alert.Spec.Suspend = true - obj.Alert.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + obj.Alert.Annotations[SuspendReasonAnnotation] = reason + } } func (a alertListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_helmrelease.go b/cmd/flux/suspend_helmrelease.go index 88d78742f3..8bfd373198 100644 --- a/cmd/flux/suspend_helmrelease.go +++ b/cmd/flux/suspend_helmrelease.go @@ -50,7 +50,9 @@ func (obj helmReleaseAdapter) isSuspended() bool { func (obj helmReleaseAdapter) setSuspended(reason string) { obj.HelmRelease.Spec.Suspend = true - obj.HelmRelease.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + obj.HelmRelease.Annotations[SuspendReasonAnnotation] = reason + } } func (a helmReleaseListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_image_repository.go b/cmd/flux/suspend_image_repository.go index 3b9f901c7c..83cdd127dd 100644 --- a/cmd/flux/suspend_image_repository.go +++ b/cmd/flux/suspend_image_repository.go @@ -49,7 +49,9 @@ func (obj imageRepositoryAdapter) isSuspended() bool { func (obj imageRepositoryAdapter) setSuspended(reason string) { obj.ImageRepository.Spec.Suspend = true - obj.ImageRepository.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + obj.ImageRepository.Annotations[SuspendReasonAnnotation] = reason + } } func (a imageRepositoryListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_image_updateauto.go b/cmd/flux/suspend_image_updateauto.go index 5649fa4ed3..89295b5b8c 100644 --- a/cmd/flux/suspend_image_updateauto.go +++ b/cmd/flux/suspend_image_updateauto.go @@ -49,7 +49,9 @@ func (update imageUpdateAutomationAdapter) isSuspended() bool { func (update imageUpdateAutomationAdapter) setSuspended(reason string) { update.ImageUpdateAutomation.Spec.Suspend = true - update.ImageUpdateAutomation.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + update.ImageUpdateAutomation.Annotations[SuspendReasonAnnotation] = reason + } } func (a imageUpdateAutomationListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_kustomization.go b/cmd/flux/suspend_kustomization.go index 7689c90450..b0ec1b8b31 100644 --- a/cmd/flux/suspend_kustomization.go +++ b/cmd/flux/suspend_kustomization.go @@ -50,7 +50,9 @@ func (obj kustomizationAdapter) isSuspended() bool { func (obj kustomizationAdapter) setSuspended(reason string) { obj.Kustomization.Spec.Suspend = true - obj.Kustomization.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + obj.Kustomization.Annotations[SuspendReasonAnnotation] = reason + } } func (a kustomizationListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_receiver.go b/cmd/flux/suspend_receiver.go index b512238bde..57ceb1d022 100644 --- a/cmd/flux/suspend_receiver.go +++ b/cmd/flux/suspend_receiver.go @@ -49,7 +49,9 @@ func (obj receiverAdapter) isSuspended() bool { func (obj receiverAdapter) setSuspended(reason string) { obj.Receiver.Spec.Suspend = true - obj.Receiver.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + obj.Receiver.Annotations[SuspendReasonAnnotation] = reason + } } func (a receiverListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_source_bucket.go b/cmd/flux/suspend_source_bucket.go index 1a625f3f78..55eef2c469 100644 --- a/cmd/flux/suspend_source_bucket.go +++ b/cmd/flux/suspend_source_bucket.go @@ -49,7 +49,9 @@ func (obj bucketAdapter) isSuspended() bool { func (obj bucketAdapter) setSuspended(reason string) { obj.Bucket.Spec.Suspend = true - obj.Bucket.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + obj.Bucket.Annotations[SuspendReasonAnnotation] = reason + } } func (a bucketListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_source_chart.go b/cmd/flux/suspend_source_chart.go index aeccf034f0..f8d471edbf 100644 --- a/cmd/flux/suspend_source_chart.go +++ b/cmd/flux/suspend_source_chart.go @@ -49,7 +49,9 @@ func (obj helmChartAdapter) isSuspended() bool { func (obj helmChartAdapter) setSuspended(reason string) { obj.HelmChart.Spec.Suspend = true - obj.HelmChart.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + obj.HelmChart.Annotations[SuspendReasonAnnotation] = reason + } } func (a helmChartListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_source_git.go b/cmd/flux/suspend_source_git.go index a40cdb05c0..f379ab8ea5 100644 --- a/cmd/flux/suspend_source_git.go +++ b/cmd/flux/suspend_source_git.go @@ -49,7 +49,9 @@ func (obj gitRepositoryAdapter) isSuspended() bool { func (obj gitRepositoryAdapter) setSuspended(reason string) { obj.GitRepository.Spec.Suspend = true - obj.GitRepository.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + obj.GitRepository.Annotations[SuspendReasonAnnotation] = reason + } } func (a gitRepositoryListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_source_helm.go b/cmd/flux/suspend_source_helm.go index 6b7a7669bc..56e883ed40 100644 --- a/cmd/flux/suspend_source_helm.go +++ b/cmd/flux/suspend_source_helm.go @@ -49,7 +49,9 @@ func (obj helmRepositoryAdapter) isSuspended() bool { func (obj helmRepositoryAdapter) setSuspended(reason string) { obj.HelmRepository.Spec.Suspend = true - obj.HelmRepository.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + obj.HelmRepository.Annotations[SuspendReasonAnnotation] = reason + } } func (a helmRepositoryListAdapter) item(i int) suspendable { diff --git a/cmd/flux/suspend_source_oci.go b/cmd/flux/suspend_source_oci.go index e756b06fc5..07fa2a4f5e 100644 --- a/cmd/flux/suspend_source_oci.go +++ b/cmd/flux/suspend_source_oci.go @@ -49,7 +49,9 @@ func (obj ociRepositoryAdapter) isSuspended() bool { func (obj ociRepositoryAdapter) setSuspended(reason string) { obj.OCIRepository.Spec.Suspend = true - obj.OCIRepository.Annotations[SuspendReasonAnnotation] = reason + if reason != "" { + obj.OCIRepository.Annotations[SuspendReasonAnnotation] = reason + } } func (a ociRepositoryListAdapter) item(i int) suspendable { From 8483b4521379804ced9f54e657e98ec4de208345 Mon Sep 17 00:00:00 2001 From: Travis Mattera Date: Wed, 13 Sep 2023 11:08:20 -0700 Subject: [PATCH 5/6] Removed comments Signed-off-by: Travis Mattera --- cmd/flux/suspend.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/flux/suspend.go b/cmd/flux/suspend.go index 5ac2ac3795..54b45fef2f 100644 --- a/cmd/flux/suspend.go +++ b/cmd/flux/suspend.go @@ -79,7 +79,6 @@ func (suspend suspendCommand) run(cmd *cobra.Command, args []string) error { return err } - // in case of all, get all in namespace and patch 'em if len(args) < 1 && suspendArgs.all { listOpts := []client.ListOption{ client.InNamespace(*kubeconfigArgs.Namespace), @@ -92,7 +91,6 @@ func (suspend suspendCommand) run(cmd *cobra.Command, args []string) error { return nil } - // when not all, patch list of args processed := make(map[string]struct{}, len(args)) for _, arg := range args { if _, has := processed[arg]; has { From b8a4a2f3ffbda0aa582c67b6b37e37e22d2669b2 Mon Sep 17 00:00:00 2001 From: Travis Mattera Date: Tue, 28 Nov 2023 20:01:16 -0800 Subject: [PATCH 6/6] Changed reason to more broadly applicable message. Signed-off-by: Travis Mattera --- cmd/flux/resume_alert.go | 4 ++-- cmd/flux/resume_helmrelease.go | 4 ++-- cmd/flux/resume_image_repository.go | 4 ++-- cmd/flux/resume_image_updateauto.go | 4 ++-- cmd/flux/resume_kustomization.go | 4 ++-- cmd/flux/resume_receiver.go | 4 ++-- cmd/flux/resume_source_bucket.go | 4 ++-- cmd/flux/resume_source_chart.go | 4 ++-- cmd/flux/resume_source_git.go | 4 ++-- cmd/flux/resume_source_helm.go | 4 ++-- cmd/flux/resume_source_oci.go | 4 ++-- cmd/flux/suspend.go | 16 ++++++++-------- cmd/flux/suspend_alert.go | 6 +++--- cmd/flux/suspend_helmrelease.go | 6 +++--- cmd/flux/suspend_image_repository.go | 6 +++--- cmd/flux/suspend_image_updateauto.go | 6 +++--- cmd/flux/suspend_kustomization.go | 6 +++--- cmd/flux/suspend_receiver.go | 6 +++--- cmd/flux/suspend_source_bucket.go | 6 +++--- cmd/flux/suspend_source_chart.go | 6 +++--- cmd/flux/suspend_source_git.go | 6 +++--- cmd/flux/suspend_source_helm.go | 6 +++--- cmd/flux/suspend_source_oci.go | 6 +++--- 23 files changed, 63 insertions(+), 63 deletions(-) diff --git a/cmd/flux/resume_alert.go b/cmd/flux/resume_alert.go index 7ed2922166..add89dd2f1 100644 --- a/cmd/flux/resume_alert.go +++ b/cmd/flux/resume_alert.go @@ -49,8 +49,8 @@ func (obj alertAdapter) getObservedGeneration() int64 { func (obj alertAdapter) setUnsuspended() { obj.Alert.Spec.Suspend = false - if _, ok := obj.Alert.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.Alert.Annotations, SuspendReasonAnnotation) + if _, ok := obj.Alert.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.Alert.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/resume_helmrelease.go b/cmd/flux/resume_helmrelease.go index 6acbd2b3e0..cd475d030f 100644 --- a/cmd/flux/resume_helmrelease.go +++ b/cmd/flux/resume_helmrelease.go @@ -52,8 +52,8 @@ func (obj helmReleaseAdapter) getObservedGeneration() int64 { func (obj helmReleaseAdapter) setUnsuspended() { obj.HelmRelease.Spec.Suspend = false - if _, ok := obj.HelmRelease.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.HelmRelease.Annotations, SuspendReasonAnnotation) + if _, ok := obj.HelmRelease.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.HelmRelease.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/resume_image_repository.go b/cmd/flux/resume_image_repository.go index b1e493642a..add2a17285 100644 --- a/cmd/flux/resume_image_repository.go +++ b/cmd/flux/resume_image_repository.go @@ -48,8 +48,8 @@ func (obj imageRepositoryAdapter) getObservedGeneration() int64 { func (obj imageRepositoryAdapter) setUnsuspended() { obj.ImageRepository.Spec.Suspend = false - if _, ok := obj.ImageRepository.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.ImageRepository.Annotations, SuspendReasonAnnotation) + if _, ok := obj.ImageRepository.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.ImageRepository.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/resume_image_updateauto.go b/cmd/flux/resume_image_updateauto.go index d0131c988c..561df49032 100644 --- a/cmd/flux/resume_image_updateauto.go +++ b/cmd/flux/resume_image_updateauto.go @@ -44,8 +44,8 @@ func init() { func (obj imageUpdateAutomationAdapter) setUnsuspended() { obj.ImageUpdateAutomation.Spec.Suspend = false - if _, ok := obj.ImageUpdateAutomation.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.ImageUpdateAutomation.Annotations, SuspendReasonAnnotation) + if _, ok := obj.ImageUpdateAutomation.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.ImageUpdateAutomation.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/resume_kustomization.go b/cmd/flux/resume_kustomization.go index ab8ed7dc21..23f231df4a 100644 --- a/cmd/flux/resume_kustomization.go +++ b/cmd/flux/resume_kustomization.go @@ -52,8 +52,8 @@ func (obj kustomizationAdapter) getObservedGeneration() int64 { func (obj kustomizationAdapter) setUnsuspended() { obj.Kustomization.Spec.Suspend = false - if _, ok := obj.Kustomization.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.Kustomization.Annotations, SuspendReasonAnnotation) + if _, ok := obj.Kustomization.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.Kustomization.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/resume_receiver.go b/cmd/flux/resume_receiver.go index 1659c6bf27..c13c25f976 100644 --- a/cmd/flux/resume_receiver.go +++ b/cmd/flux/resume_receiver.go @@ -49,8 +49,8 @@ func (obj receiverAdapter) getObservedGeneration() int64 { func (obj receiverAdapter) setUnsuspended() { obj.Receiver.Spec.Suspend = false - if _, ok := obj.Receiver.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.Receiver.Annotations, SuspendReasonAnnotation) + if _, ok := obj.Receiver.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.Receiver.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/resume_source_bucket.go b/cmd/flux/resume_source_bucket.go index de0ec2b652..dd2ba4dae5 100644 --- a/cmd/flux/resume_source_bucket.go +++ b/cmd/flux/resume_source_bucket.go @@ -48,8 +48,8 @@ func (obj bucketAdapter) getObservedGeneration() int64 { func (obj bucketAdapter) setUnsuspended() { obj.Bucket.Spec.Suspend = false - if _, ok := obj.Bucket.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.Bucket.Annotations, SuspendReasonAnnotation) + if _, ok := obj.Bucket.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.Bucket.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/resume_source_chart.go b/cmd/flux/resume_source_chart.go index beb3ed974e..245c344531 100644 --- a/cmd/flux/resume_source_chart.go +++ b/cmd/flux/resume_source_chart.go @@ -50,8 +50,8 @@ func (obj helmChartAdapter) getObservedGeneration() int64 { func (obj helmChartAdapter) setUnsuspended() { obj.HelmChart.Spec.Suspend = false - if _, ok := obj.HelmChart.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.HelmChart.Annotations, SuspendReasonAnnotation) + if _, ok := obj.HelmChart.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.HelmChart.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/resume_source_git.go b/cmd/flux/resume_source_git.go index 23289870d1..120a09374c 100644 --- a/cmd/flux/resume_source_git.go +++ b/cmd/flux/resume_source_git.go @@ -48,8 +48,8 @@ func (obj gitRepositoryAdapter) getObservedGeneration() int64 { func (obj gitRepositoryAdapter) setUnsuspended() { obj.GitRepository.Spec.Suspend = false - if _, ok := obj.GitRepository.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.GitRepository.Annotations, SuspendReasonAnnotation) + if _, ok := obj.GitRepository.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.GitRepository.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/resume_source_helm.go b/cmd/flux/resume_source_helm.go index 54531cb81d..7d10aed53c 100644 --- a/cmd/flux/resume_source_helm.go +++ b/cmd/flux/resume_source_helm.go @@ -48,8 +48,8 @@ func (obj helmRepositoryAdapter) getObservedGeneration() int64 { func (obj helmRepositoryAdapter) setUnsuspended() { obj.HelmRepository.Spec.Suspend = false - if _, ok := obj.HelmRepository.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.HelmRepository.Annotations, SuspendReasonAnnotation) + if _, ok := obj.HelmRepository.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.HelmRepository.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/resume_source_oci.go b/cmd/flux/resume_source_oci.go index db40ec0558..b724feb62d 100644 --- a/cmd/flux/resume_source_oci.go +++ b/cmd/flux/resume_source_oci.go @@ -48,8 +48,8 @@ func (obj ociRepositoryAdapter) getObservedGeneration() int64 { func (obj ociRepositoryAdapter) setUnsuspended() { obj.OCIRepository.Spec.Suspend = false - if _, ok := obj.OCIRepository.Annotations[SuspendReasonAnnotation]; ok { - delete(obj.OCIRepository.Annotations, SuspendReasonAnnotation) + if _, ok := obj.OCIRepository.Annotations[SuspendMessageAnnotation]; ok { + delete(obj.OCIRepository.Annotations, SuspendMessageAnnotation) } } diff --git a/cmd/flux/suspend.go b/cmd/flux/suspend.go index 54b45fef2f..ad4d745bac 100644 --- a/cmd/flux/suspend.go +++ b/cmd/flux/suspend.go @@ -34,8 +34,8 @@ var suspendCmd = &cobra.Command{ } type SuspendFlags struct { - all bool - reason string + all bool + message string } var suspendArgs SuspendFlags @@ -43,8 +43,8 @@ var suspendArgs SuspendFlags func init() { suspendCmd.PersistentFlags().BoolVarP(&suspendArgs.all, "all", "", false, "suspend all resources in that namespace") - suspendCmd.PersistentFlags().StringVarP(&suspendArgs.reason, "reason", "r", "", - "set a reason for why the resource is suspended, the reason will show up under the suspend.toolkit.fluxcd.io/reason annotation") + suspendCmd.PersistentFlags().StringVarP(&suspendArgs.message, "message", "m", "", + "set a message for the resource being suspended (stored in the suspend.toolkit.fluxcd.io/message annotation)") rootCmd.AddCommand(suspendCmd) } @@ -52,7 +52,7 @@ type suspendable interface { adapter copyable isSuspended() bool - setSuspended(reason string) + setSuspended(message string) } type suspendCommand struct { @@ -133,7 +133,7 @@ func (suspend suspendCommand) patch(ctx context.Context, kubeClient client.WithW obj := suspend.list.item(i) patch := client.MergeFrom(obj.deepCopyClientObject()) - obj.setSuspended(suspendArgs.reason) + obj.setSuspended(suspendArgs.message) if err := kubeClient.Patch(ctx, obj.asClientObject(), patch); err != nil { return err } @@ -144,5 +144,5 @@ func (suspend suspendCommand) patch(ctx context.Context, kubeClient client.WithW return nil } -// SuspendReasonAnnotation is the metadata key used to store the reason for resource suspension -const SuspendReasonAnnotation string = "suspend.toolkit.fluxcd.io/reason" +// SuspendMessageAnnotation is the metadata key used to store a message related to resource suspension +const SuspendMessageAnnotation string = "suspend.toolkit.fluxcd.io/message" diff --git a/cmd/flux/suspend_alert.go b/cmd/flux/suspend_alert.go index be750c9f9f..c0251d5453 100644 --- a/cmd/flux/suspend_alert.go +++ b/cmd/flux/suspend_alert.go @@ -47,10 +47,10 @@ func (obj alertAdapter) isSuspended() bool { return obj.Alert.Spec.Suspend } -func (obj alertAdapter) setSuspended(reason string) { +func (obj alertAdapter) setSuspended(message string) { obj.Alert.Spec.Suspend = true - if reason != "" { - obj.Alert.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + obj.Alert.Annotations[SuspendMessageAnnotation] = message } } diff --git a/cmd/flux/suspend_helmrelease.go b/cmd/flux/suspend_helmrelease.go index 8bfd373198..5675da7984 100644 --- a/cmd/flux/suspend_helmrelease.go +++ b/cmd/flux/suspend_helmrelease.go @@ -48,10 +48,10 @@ func (obj helmReleaseAdapter) isSuspended() bool { return obj.HelmRelease.Spec.Suspend } -func (obj helmReleaseAdapter) setSuspended(reason string) { +func (obj helmReleaseAdapter) setSuspended(message string) { obj.HelmRelease.Spec.Suspend = true - if reason != "" { - obj.HelmRelease.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + obj.HelmRelease.Annotations[SuspendMessageAnnotation] = message } } diff --git a/cmd/flux/suspend_image_repository.go b/cmd/flux/suspend_image_repository.go index 83cdd127dd..56b2a775e5 100644 --- a/cmd/flux/suspend_image_repository.go +++ b/cmd/flux/suspend_image_repository.go @@ -47,10 +47,10 @@ func (obj imageRepositoryAdapter) isSuspended() bool { return obj.ImageRepository.Spec.Suspend } -func (obj imageRepositoryAdapter) setSuspended(reason string) { +func (obj imageRepositoryAdapter) setSuspended(message string) { obj.ImageRepository.Spec.Suspend = true - if reason != "" { - obj.ImageRepository.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + obj.ImageRepository.Annotations[SuspendMessageAnnotation] = message } } diff --git a/cmd/flux/suspend_image_updateauto.go b/cmd/flux/suspend_image_updateauto.go index 89295b5b8c..bde79667cb 100644 --- a/cmd/flux/suspend_image_updateauto.go +++ b/cmd/flux/suspend_image_updateauto.go @@ -47,10 +47,10 @@ func (update imageUpdateAutomationAdapter) isSuspended() bool { return update.ImageUpdateAutomation.Spec.Suspend } -func (update imageUpdateAutomationAdapter) setSuspended(reason string) { +func (update imageUpdateAutomationAdapter) setSuspended(message string) { update.ImageUpdateAutomation.Spec.Suspend = true - if reason != "" { - update.ImageUpdateAutomation.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + update.ImageUpdateAutomation.Annotations[SuspendMessageAnnotation] = message } } diff --git a/cmd/flux/suspend_kustomization.go b/cmd/flux/suspend_kustomization.go index b0ec1b8b31..74bd78d5dd 100644 --- a/cmd/flux/suspend_kustomization.go +++ b/cmd/flux/suspend_kustomization.go @@ -48,10 +48,10 @@ func (obj kustomizationAdapter) isSuspended() bool { return obj.Kustomization.Spec.Suspend } -func (obj kustomizationAdapter) setSuspended(reason string) { +func (obj kustomizationAdapter) setSuspended(message string) { obj.Kustomization.Spec.Suspend = true - if reason != "" { - obj.Kustomization.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + obj.Kustomization.Annotations[SuspendMessageAnnotation] = message } } diff --git a/cmd/flux/suspend_receiver.go b/cmd/flux/suspend_receiver.go index 57ceb1d022..445c5ac785 100644 --- a/cmd/flux/suspend_receiver.go +++ b/cmd/flux/suspend_receiver.go @@ -47,10 +47,10 @@ func (obj receiverAdapter) isSuspended() bool { return obj.Receiver.Spec.Suspend } -func (obj receiverAdapter) setSuspended(reason string) { +func (obj receiverAdapter) setSuspended(message string) { obj.Receiver.Spec.Suspend = true - if reason != "" { - obj.Receiver.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + obj.Receiver.Annotations[SuspendMessageAnnotation] = message } } diff --git a/cmd/flux/suspend_source_bucket.go b/cmd/flux/suspend_source_bucket.go index 55eef2c469..afd963ab27 100644 --- a/cmd/flux/suspend_source_bucket.go +++ b/cmd/flux/suspend_source_bucket.go @@ -47,10 +47,10 @@ func (obj bucketAdapter) isSuspended() bool { return obj.Bucket.Spec.Suspend } -func (obj bucketAdapter) setSuspended(reason string) { +func (obj bucketAdapter) setSuspended(message string) { obj.Bucket.Spec.Suspend = true - if reason != "" { - obj.Bucket.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + obj.Bucket.Annotations[SuspendMessageAnnotation] = message } } diff --git a/cmd/flux/suspend_source_chart.go b/cmd/flux/suspend_source_chart.go index f8d471edbf..64a3005e6f 100644 --- a/cmd/flux/suspend_source_chart.go +++ b/cmd/flux/suspend_source_chart.go @@ -47,10 +47,10 @@ func (obj helmChartAdapter) isSuspended() bool { return obj.HelmChart.Spec.Suspend } -func (obj helmChartAdapter) setSuspended(reason string) { +func (obj helmChartAdapter) setSuspended(message string) { obj.HelmChart.Spec.Suspend = true - if reason != "" { - obj.HelmChart.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + obj.HelmChart.Annotations[SuspendMessageAnnotation] = message } } diff --git a/cmd/flux/suspend_source_git.go b/cmd/flux/suspend_source_git.go index f379ab8ea5..a60164d79f 100644 --- a/cmd/flux/suspend_source_git.go +++ b/cmd/flux/suspend_source_git.go @@ -47,10 +47,10 @@ func (obj gitRepositoryAdapter) isSuspended() bool { return obj.GitRepository.Spec.Suspend } -func (obj gitRepositoryAdapter) setSuspended(reason string) { +func (obj gitRepositoryAdapter) setSuspended(message string) { obj.GitRepository.Spec.Suspend = true - if reason != "" { - obj.GitRepository.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + obj.GitRepository.Annotations[SuspendMessageAnnotation] = message } } diff --git a/cmd/flux/suspend_source_helm.go b/cmd/flux/suspend_source_helm.go index 56e883ed40..282ddd97bb 100644 --- a/cmd/flux/suspend_source_helm.go +++ b/cmd/flux/suspend_source_helm.go @@ -47,10 +47,10 @@ func (obj helmRepositoryAdapter) isSuspended() bool { return obj.HelmRepository.Spec.Suspend } -func (obj helmRepositoryAdapter) setSuspended(reason string) { +func (obj helmRepositoryAdapter) setSuspended(message string) { obj.HelmRepository.Spec.Suspend = true - if reason != "" { - obj.HelmRepository.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + obj.HelmRepository.Annotations[SuspendMessageAnnotation] = message } } diff --git a/cmd/flux/suspend_source_oci.go b/cmd/flux/suspend_source_oci.go index 07fa2a4f5e..acf0057bde 100644 --- a/cmd/flux/suspend_source_oci.go +++ b/cmd/flux/suspend_source_oci.go @@ -47,10 +47,10 @@ func (obj ociRepositoryAdapter) isSuspended() bool { return obj.OCIRepository.Spec.Suspend } -func (obj ociRepositoryAdapter) setSuspended(reason string) { +func (obj ociRepositoryAdapter) setSuspended(message string) { obj.OCIRepository.Spec.Suspend = true - if reason != "" { - obj.OCIRepository.Annotations[SuspendReasonAnnotation] = reason + if message != "" { + obj.OCIRepository.Annotations[SuspendMessageAnnotation] = message } }