diff --git a/webhooks/common.go b/webhooks/common.go index 1423fb991..138087ebb 100644 --- a/webhooks/common.go +++ b/webhooks/common.go @@ -11,7 +11,10 @@ import ( ) func OpenFeatureEnabledAnnotationIndex(o client.Object) []string { - pod := o.(*corev1.Pod) + pod, ok := o.(*corev1.Pod) + if !ok { + return []string{"false"} + } if pod.ObjectMeta.Annotations == nil { return []string{ "false", diff --git a/webhooks/common_test.go b/webhooks/common_test.go index 2b46446ae..5fe8bcac9 100644 --- a/webhooks/common_test.go +++ b/webhooks/common_test.go @@ -21,6 +21,10 @@ func TestOpenFeatureEnabledAnnotationIndex(t *testing.T) { want []string }{ { + name: "not a pod", + o: &corev1.ConfigMap{}, + want: []string{"false"}, + }, { name: "no annotations", o: &corev1.Pod{}, want: []string{"false"},