mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-08 00:37:27 +00:00
Changed reason to more broadly applicable message.
Signed-off-by: Travis Mattera <travis@mattera.io>
This commit is contained in:
parent
8483b45213
commit
b8a4a2f3ff
23 changed files with 63 additions and 63 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue