Skip to content

Commit

Permalink
chore: update IsManageableSystemNamespace (#1527)
Browse files Browse the repository at this point in the history
The IsManageableSystemNamespace function currently requires typed
namespace objects to have their GroupVersionKind set. This update
adds checks for the v1.Namespace type to avoid that requirement.
  • Loading branch information
karlkfi authored Jan 9, 2025
1 parent 0aecd91 commit fa000ae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/syncer/differ/special_namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package differ
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"kpt.dev/configsync/pkg/kinds"
"kpt.dev/configsync/pkg/policycontroller"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -38,7 +39,13 @@ var SpecialNamespaces = map[string]bool{

// IsManageableSystemNamespace returns if the input namespace is a manageable system namespace.
func IsManageableSystemNamespace(o client.Object) bool {
if o.GetObjectKind().GroupVersionKind().GroupKind() != kinds.Namespace().GroupKind() {
switch t := o.(type) {
case *corev1.Namespace:
case *unstructured.Unstructured:
if t.GroupVersionKind().GroupKind() != kinds.Namespace().GroupKind() {
return false
}
default:
return false
}
return SpecialNamespaces[o.GetName()]
Expand Down

0 comments on commit fa000ae

Please sign in to comment.