Skip to content

Commit

Permalink
Ignore status fields when comparing resources
Browse files Browse the repository at this point in the history
  • Loading branch information
aruiz14 committed Jun 17, 2024
1 parent 3ee97c0 commit 03f433c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/cmd/agent/deployer/normalizers/norm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func (n Norm) Normalize(un *unstructured.Unstructured) error {
func New(lives objectset.ObjectByGVK, additions ...diff.Normalizer) Norm {
n := Norm{
normalizers: []diff.Normalizer{
// Status fields are normally subresources which can't be influenced by resource updates
&StatusNormalizer{},
&MutatingWebhookNormalizer{
Live: lives,
},
Expand Down
13 changes: 13 additions & 0 deletions internal/cmd/agent/deployer/normalizers/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package normalizers

import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

// StatusNormalizer removes a top-level "status" fields from the object, if present
type StatusNormalizer struct{}

func (j StatusNormalizer) Normalize(un *unstructured.Unstructured) error {
unstructured.RemoveNestedField(un.Object, "status")
return nil
}

0 comments on commit 03f433c

Please sign in to comment.