Skip to content

Commit

Permalink
Merge pull request #921 from fluxcd/backport-920-to-release/v1.0.x
Browse files Browse the repository at this point in the history
[release/v1.0.x] Exclude skipped resources from apply events
  • Loading branch information
stefanprodan authored Jul 6, 2023
2 parents 568efe3 + d1a0c99 commit b769bd9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/controller/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand All @@ -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")
}
}
Expand All @@ -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")
}
}
Expand Down
15 changes: 15 additions & 0 deletions internal/controller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
}

0 comments on commit b769bd9

Please sign in to comment.