Exclude skipped resources from apply events

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan 2023-07-06 10:38:12 +03:00
parent 0fe37838c8
commit b1d2b72b11
No known key found for this signature in database
GPG Key ID: 3299AEB0E4085BAF
2 changed files with 18 additions and 3 deletions

View File

@ -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")
}
}

View File

@ -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
}
}