mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #74448 from liggitt/webhook-gvk
Explicitly set GVK when sending objects to webhooks
This commit is contained in:
commit
7d67315d28
@ -37,5 +37,7 @@ func ConvertToGVK(obj runtime.Object, gvk schema.GroupVersionKind, o admission.O
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Explicitly set the GVK
|
||||
out.GetObjectKind().SetGroupVersionKind(gvk)
|
||||
return out, nil
|
||||
}
|
||||
|
@ -62,6 +62,10 @@ func TestConvertToGVK(t *testing.T) {
|
||||
},
|
||||
gvk: examplev1.SchemeGroupVersion.WithKind("Pod"),
|
||||
expectedObj: &examplev1.Pod{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "example.apiserver.k8s.io/v1",
|
||||
Kind: "Pod",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "pod1",
|
||||
Labels: map[string]string{
|
||||
@ -87,6 +91,10 @@ func TestConvertToGVK(t *testing.T) {
|
||||
},
|
||||
gvk: example2v1.SchemeGroupVersion.WithKind("ReplicaSet"),
|
||||
expectedObj: &example2v1.ReplicaSet{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "example2.apiserver.k8s.io/v1",
|
||||
Kind: "ReplicaSet",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "rs1",
|
||||
Labels: map[string]string{
|
||||
|
Loading…
Reference in New Issue
Block a user