Skip to content

Commit

Permalink
fix: ensure appset don't attempt to remove application kind in patch …
Browse files Browse the repository at this point in the history
…requests (#16056) (#16073)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
Co-authored-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
  • Loading branch information
gcp-cherry-pick-bot[bot] and alexmt authored Oct 23, 2023
1 parent 55e5d6b commit eaa9af2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions applicationset/utils/createOrUpdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

Expand Down Expand Up @@ -78,6 +79,12 @@ func CreateOrUpdate(ctx context.Context, c client.Client, obj client.Object, f c
return a.Namespace == b.Namespace && a.Name == b.Name && a.Server == b.Server
},
)
// make sure updated object has the same apiVersion & kind as original object
if objKind, ok := obj.(schema.ObjectKind); ok {
if existingKind, ok := existing.(schema.ObjectKind); ok {
existingKind.SetGroupVersionKind(objKind.GroupVersionKind())
}
}

if equality.DeepEqual(existing, obj) {
return controllerutil.OperationResultNone, nil
Expand Down

0 comments on commit eaa9af2

Please sign in to comment.