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 <travis@mattera.io>
pull/4232/head
Travis Mattera 2 years ago
parent 59c759e885
commit 0ba9db560b
No known key found for this signature in database
GPG Key ID: 6E9A8A6A0A74CA52

@ -43,7 +43,7 @@ var suspendArgs SuspendFlags
func init() { func init() {
suspendCmd.PersistentFlags().BoolVarP(&suspendArgs.all, "all", "", false, suspendCmd.PersistentFlags().BoolVarP(&suspendArgs.all, "all", "", false,
"suspend all resources in that namespace") "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") "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) rootCmd.AddCommand(suspendCmd)
} }

@ -49,8 +49,10 @@ func (obj alertAdapter) isSuspended() bool {
func (obj alertAdapter) setSuspended(reason string) { func (obj alertAdapter) setSuspended(reason string) {
obj.Alert.Spec.Suspend = true obj.Alert.Spec.Suspend = true
if reason != "" {
obj.Alert.Annotations[SuspendReasonAnnotation] = reason obj.Alert.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a alertListAdapter) item(i int) suspendable { func (a alertListAdapter) item(i int) suspendable {
return &alertAdapter{&a.AlertList.Items[i]} return &alertAdapter{&a.AlertList.Items[i]}

@ -50,8 +50,10 @@ func (obj helmReleaseAdapter) isSuspended() bool {
func (obj helmReleaseAdapter) setSuspended(reason string) { func (obj helmReleaseAdapter) setSuspended(reason string) {
obj.HelmRelease.Spec.Suspend = true obj.HelmRelease.Spec.Suspend = true
if reason != "" {
obj.HelmRelease.Annotations[SuspendReasonAnnotation] = reason obj.HelmRelease.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a helmReleaseListAdapter) item(i int) suspendable { func (a helmReleaseListAdapter) item(i int) suspendable {
return &helmReleaseAdapter{&a.HelmReleaseList.Items[i]} return &helmReleaseAdapter{&a.HelmReleaseList.Items[i]}

@ -49,8 +49,10 @@ func (obj imageRepositoryAdapter) isSuspended() bool {
func (obj imageRepositoryAdapter) setSuspended(reason string) { func (obj imageRepositoryAdapter) setSuspended(reason string) {
obj.ImageRepository.Spec.Suspend = true obj.ImageRepository.Spec.Suspend = true
if reason != "" {
obj.ImageRepository.Annotations[SuspendReasonAnnotation] = reason obj.ImageRepository.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a imageRepositoryListAdapter) item(i int) suspendable { func (a imageRepositoryListAdapter) item(i int) suspendable {
return &imageRepositoryAdapter{&a.ImageRepositoryList.Items[i]} return &imageRepositoryAdapter{&a.ImageRepositoryList.Items[i]}

@ -49,8 +49,10 @@ func (update imageUpdateAutomationAdapter) isSuspended() bool {
func (update imageUpdateAutomationAdapter) setSuspended(reason string) { func (update imageUpdateAutomationAdapter) setSuspended(reason string) {
update.ImageUpdateAutomation.Spec.Suspend = true update.ImageUpdateAutomation.Spec.Suspend = true
if reason != "" {
update.ImageUpdateAutomation.Annotations[SuspendReasonAnnotation] = reason update.ImageUpdateAutomation.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a imageUpdateAutomationListAdapter) item(i int) suspendable { func (a imageUpdateAutomationListAdapter) item(i int) suspendable {
return &imageUpdateAutomationAdapter{&a.ImageUpdateAutomationList.Items[i]} return &imageUpdateAutomationAdapter{&a.ImageUpdateAutomationList.Items[i]}

@ -50,8 +50,10 @@ func (obj kustomizationAdapter) isSuspended() bool {
func (obj kustomizationAdapter) setSuspended(reason string) { func (obj kustomizationAdapter) setSuspended(reason string) {
obj.Kustomization.Spec.Suspend = true obj.Kustomization.Spec.Suspend = true
if reason != "" {
obj.Kustomization.Annotations[SuspendReasonAnnotation] = reason obj.Kustomization.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a kustomizationListAdapter) item(i int) suspendable { func (a kustomizationListAdapter) item(i int) suspendable {
return &kustomizationAdapter{&a.KustomizationList.Items[i]} return &kustomizationAdapter{&a.KustomizationList.Items[i]}

@ -49,8 +49,10 @@ func (obj receiverAdapter) isSuspended() bool {
func (obj receiverAdapter) setSuspended(reason string) { func (obj receiverAdapter) setSuspended(reason string) {
obj.Receiver.Spec.Suspend = true obj.Receiver.Spec.Suspend = true
if reason != "" {
obj.Receiver.Annotations[SuspendReasonAnnotation] = reason obj.Receiver.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a receiverListAdapter) item(i int) suspendable { func (a receiverListAdapter) item(i int) suspendable {
return &receiverAdapter{&a.ReceiverList.Items[i]} return &receiverAdapter{&a.ReceiverList.Items[i]}

@ -49,8 +49,10 @@ func (obj bucketAdapter) isSuspended() bool {
func (obj bucketAdapter) setSuspended(reason string) { func (obj bucketAdapter) setSuspended(reason string) {
obj.Bucket.Spec.Suspend = true obj.Bucket.Spec.Suspend = true
if reason != "" {
obj.Bucket.Annotations[SuspendReasonAnnotation] = reason obj.Bucket.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a bucketListAdapter) item(i int) suspendable { func (a bucketListAdapter) item(i int) suspendable {
return &bucketAdapter{&a.BucketList.Items[i]} return &bucketAdapter{&a.BucketList.Items[i]}

@ -49,8 +49,10 @@ func (obj helmChartAdapter) isSuspended() bool {
func (obj helmChartAdapter) setSuspended(reason string) { func (obj helmChartAdapter) setSuspended(reason string) {
obj.HelmChart.Spec.Suspend = true obj.HelmChart.Spec.Suspend = true
if reason != "" {
obj.HelmChart.Annotations[SuspendReasonAnnotation] = reason obj.HelmChart.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a helmChartListAdapter) item(i int) suspendable { func (a helmChartListAdapter) item(i int) suspendable {
return &helmChartAdapter{&a.HelmChartList.Items[i]} return &helmChartAdapter{&a.HelmChartList.Items[i]}

@ -49,8 +49,10 @@ func (obj gitRepositoryAdapter) isSuspended() bool {
func (obj gitRepositoryAdapter) setSuspended(reason string) { func (obj gitRepositoryAdapter) setSuspended(reason string) {
obj.GitRepository.Spec.Suspend = true obj.GitRepository.Spec.Suspend = true
if reason != "" {
obj.GitRepository.Annotations[SuspendReasonAnnotation] = reason obj.GitRepository.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a gitRepositoryListAdapter) item(i int) suspendable { func (a gitRepositoryListAdapter) item(i int) suspendable {
return &gitRepositoryAdapter{&a.GitRepositoryList.Items[i]} return &gitRepositoryAdapter{&a.GitRepositoryList.Items[i]}

@ -49,8 +49,10 @@ func (obj helmRepositoryAdapter) isSuspended() bool {
func (obj helmRepositoryAdapter) setSuspended(reason string) { func (obj helmRepositoryAdapter) setSuspended(reason string) {
obj.HelmRepository.Spec.Suspend = true obj.HelmRepository.Spec.Suspend = true
if reason != "" {
obj.HelmRepository.Annotations[SuspendReasonAnnotation] = reason obj.HelmRepository.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a helmRepositoryListAdapter) item(i int) suspendable { func (a helmRepositoryListAdapter) item(i int) suspendable {
return &helmRepositoryAdapter{&a.HelmRepositoryList.Items[i]} return &helmRepositoryAdapter{&a.HelmRepositoryList.Items[i]}

@ -49,8 +49,10 @@ func (obj ociRepositoryAdapter) isSuspended() bool {
func (obj ociRepositoryAdapter) setSuspended(reason string) { func (obj ociRepositoryAdapter) setSuspended(reason string) {
obj.OCIRepository.Spec.Suspend = true obj.OCIRepository.Spec.Suspend = true
if reason != "" {
obj.OCIRepository.Annotations[SuspendReasonAnnotation] = reason obj.OCIRepository.Annotations[SuspendReasonAnnotation] = reason
} }
}
func (a ociRepositoryListAdapter) item(i int) suspendable { func (a ociRepositoryListAdapter) item(i int) suspendable {
return &ociRepositoryAdapter{&a.OCIRepositoryList.Items[i]} return &ociRepositoryAdapter{&a.OCIRepositoryList.Items[i]}

Loading…
Cancel
Save