Commit 69e5fbe8 authored by Jordan Liggitt's avatar Jordan Liggitt

Explicitly set GVK when sending objects to webhooks

parent c27b913f
...@@ -43,6 +43,8 @@ func (c *convertor) ConvertToGVK(obj runtime.Object, gvk schema.GroupVersionKind ...@@ -43,6 +43,8 @@ func (c *convertor) ConvertToGVK(obj runtime.Object, gvk schema.GroupVersionKind
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Explicitly set the GVK
out.GetObjectKind().SetGroupVersionKind(gvk)
return out, nil return out, nil
} }
......
...@@ -61,6 +61,10 @@ func TestConvertToGVK(t *testing.T) { ...@@ -61,6 +61,10 @@ func TestConvertToGVK(t *testing.T) {
}, },
gvk: examplev1.SchemeGroupVersion.WithKind("Pod"), gvk: examplev1.SchemeGroupVersion.WithKind("Pod"),
expectedObj: &examplev1.Pod{ expectedObj: &examplev1.Pod{
TypeMeta: metav1.TypeMeta{
APIVersion: "example.apiserver.k8s.io/v1",
Kind: "Pod",
},
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "pod1", Name: "pod1",
Labels: map[string]string{ Labels: map[string]string{
...@@ -86,6 +90,10 @@ func TestConvertToGVK(t *testing.T) { ...@@ -86,6 +90,10 @@ func TestConvertToGVK(t *testing.T) {
}, },
gvk: example2v1.SchemeGroupVersion.WithKind("ReplicaSet"), gvk: example2v1.SchemeGroupVersion.WithKind("ReplicaSet"),
expectedObj: &example2v1.ReplicaSet{ expectedObj: &example2v1.ReplicaSet{
TypeMeta: metav1.TypeMeta{
APIVersion: "example2.apiserver.k8s.io/v1",
Kind: "ReplicaSet",
},
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "rs1", Name: "rs1",
Labels: map[string]string{ Labels: map[string]string{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment