diff --git a/internal/controller/kustomization_controller.go b/internal/controller/kustomization_controller.go index 84f43e4e..3def3efc 100644 --- a/internal/controller/kustomization_controller.go +++ b/internal/controller/kustomization_controller.go @@ -741,7 +741,7 @@ func (r *KustomizationReconciler) apply(ctx context.Context, if changeSet != nil && len(changeSet.Entries) > 0 { log.Info("server-side apply for cluster definitions completed", "output", changeSet.ToMap()) for _, change := range changeSet.Entries { - if change.Action != ssa.UnchangedAction { + if HasChanged(change.Action) { changeSetLog.WriteString(change.String() + "\n") } } @@ -766,7 +766,7 @@ func (r *KustomizationReconciler) apply(ctx context.Context, if changeSet != nil && len(changeSet.Entries) > 0 { log.Info("server-side apply for cluster class types completed", "output", changeSet.ToMap()) for _, change := range changeSet.Entries { - if change.Action != ssa.UnchangedAction { + if HasChanged(change.Action) { changeSetLog.WriteString(change.String() + "\n") } } @@ -792,7 +792,7 @@ func (r *KustomizationReconciler) apply(ctx context.Context, if changeSet != nil && len(changeSet.Entries) > 0 { log.Info("server-side apply completed", "output", changeSet.ToMap(), "revision", revision) for _, change := range changeSet.Entries { - if change.Action != ssa.UnchangedAction { + if HasChanged(change.Action) { changeSetLog.WriteString(change.String() + "\n") } } diff --git a/internal/controller/utils.go b/internal/controller/utils.go index b9135a30..c186fdec 100644 --- a/internal/controller/utils.go +++ b/internal/controller/utils.go @@ -20,6 +20,8 @@ import ( "fmt" "os" "path/filepath" + + "github.com/fluxcd/pkg/ssa" ) // MkdirTempAbs creates a tmp dir and returns the absolute path to the dir. @@ -36,3 +38,16 @@ func MkdirTempAbs(dir, pattern string) (string, error) { } return tmpDir, nil } + +// HasChanged evaluates the given action and returns true +// if the action type matches a resource mutation or deletion. +func HasChanged(action ssa.Action) bool { + switch action { + case ssa.SkippedAction: + return false + case ssa.UnchangedAction: + return false + default: + return true + } +}