Skip to content

Commit 0ba9db5

Browse files
committed
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 <[email protected]>
1 parent 59c759e commit 0ba9db5

12 files changed

+34
-12
lines changed

cmd/flux/suspend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var suspendArgs SuspendFlags
4343
func init() {
4444
suspendCmd.PersistentFlags().BoolVarP(&suspendArgs.all, "all", "", false,
4545
"suspend all resources in that namespace")
46-
suspendCmd.PersistentFlags().StringVarP(&suspendArgs.reason, "reason", "r", "suspended",
46+
suspendCmd.PersistentFlags().StringVarP(&suspendArgs.reason, "reason", "r", "",
4747
"set a reason for why the resource is suspended, the reason will show up under the suspend.toolkit.fluxcd.io/reason annotation")
4848
rootCmd.AddCommand(suspendCmd)
4949
}

cmd/flux/suspend_alert.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func (obj alertAdapter) isSuspended() bool {
4949

5050
func (obj alertAdapter) setSuspended(reason string) {
5151
obj.Alert.Spec.Suspend = true
52-
obj.Alert.Annotations[SuspendReasonAnnotation] = reason
52+
if reason != "" {
53+
obj.Alert.Annotations[SuspendReasonAnnotation] = reason
54+
}
5355
}
5456

5557
func (a alertListAdapter) item(i int) suspendable {

cmd/flux/suspend_helmrelease.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ func (obj helmReleaseAdapter) isSuspended() bool {
5050

5151
func (obj helmReleaseAdapter) setSuspended(reason string) {
5252
obj.HelmRelease.Spec.Suspend = true
53-
obj.HelmRelease.Annotations[SuspendReasonAnnotation] = reason
53+
if reason != "" {
54+
obj.HelmRelease.Annotations[SuspendReasonAnnotation] = reason
55+
}
5456
}
5557

5658
func (a helmReleaseListAdapter) item(i int) suspendable {

cmd/flux/suspend_image_repository.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func (obj imageRepositoryAdapter) isSuspended() bool {
4949

5050
func (obj imageRepositoryAdapter) setSuspended(reason string) {
5151
obj.ImageRepository.Spec.Suspend = true
52-
obj.ImageRepository.Annotations[SuspendReasonAnnotation] = reason
52+
if reason != "" {
53+
obj.ImageRepository.Annotations[SuspendReasonAnnotation] = reason
54+
}
5355
}
5456

5557
func (a imageRepositoryListAdapter) item(i int) suspendable {

cmd/flux/suspend_image_updateauto.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func (update imageUpdateAutomationAdapter) isSuspended() bool {
4949

5050
func (update imageUpdateAutomationAdapter) setSuspended(reason string) {
5151
update.ImageUpdateAutomation.Spec.Suspend = true
52-
update.ImageUpdateAutomation.Annotations[SuspendReasonAnnotation] = reason
52+
if reason != "" {
53+
update.ImageUpdateAutomation.Annotations[SuspendReasonAnnotation] = reason
54+
}
5355
}
5456

5557
func (a imageUpdateAutomationListAdapter) item(i int) suspendable {

cmd/flux/suspend_kustomization.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ func (obj kustomizationAdapter) isSuspended() bool {
5050

5151
func (obj kustomizationAdapter) setSuspended(reason string) {
5252
obj.Kustomization.Spec.Suspend = true
53-
obj.Kustomization.Annotations[SuspendReasonAnnotation] = reason
53+
if reason != "" {
54+
obj.Kustomization.Annotations[SuspendReasonAnnotation] = reason
55+
}
5456
}
5557

5658
func (a kustomizationListAdapter) item(i int) suspendable {

cmd/flux/suspend_receiver.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func (obj receiverAdapter) isSuspended() bool {
4949

5050
func (obj receiverAdapter) setSuspended(reason string) {
5151
obj.Receiver.Spec.Suspend = true
52-
obj.Receiver.Annotations[SuspendReasonAnnotation] = reason
52+
if reason != "" {
53+
obj.Receiver.Annotations[SuspendReasonAnnotation] = reason
54+
}
5355
}
5456

5557
func (a receiverListAdapter) item(i int) suspendable {

cmd/flux/suspend_source_bucket.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func (obj bucketAdapter) isSuspended() bool {
4949

5050
func (obj bucketAdapter) setSuspended(reason string) {
5151
obj.Bucket.Spec.Suspend = true
52-
obj.Bucket.Annotations[SuspendReasonAnnotation] = reason
52+
if reason != "" {
53+
obj.Bucket.Annotations[SuspendReasonAnnotation] = reason
54+
}
5355
}
5456

5557
func (a bucketListAdapter) item(i int) suspendable {

cmd/flux/suspend_source_chart.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func (obj helmChartAdapter) isSuspended() bool {
4949

5050
func (obj helmChartAdapter) setSuspended(reason string) {
5151
obj.HelmChart.Spec.Suspend = true
52-
obj.HelmChart.Annotations[SuspendReasonAnnotation] = reason
52+
if reason != "" {
53+
obj.HelmChart.Annotations[SuspendReasonAnnotation] = reason
54+
}
5355
}
5456

5557
func (a helmChartListAdapter) item(i int) suspendable {

cmd/flux/suspend_source_git.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func (obj gitRepositoryAdapter) isSuspended() bool {
4949

5050
func (obj gitRepositoryAdapter) setSuspended(reason string) {
5151
obj.GitRepository.Spec.Suspend = true
52-
obj.GitRepository.Annotations[SuspendReasonAnnotation] = reason
52+
if reason != "" {
53+
obj.GitRepository.Annotations[SuspendReasonAnnotation] = reason
54+
}
5355
}
5456

5557
func (a gitRepositoryListAdapter) item(i int) suspendable {

0 commit comments

Comments
 (0)