Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
Signed-off-by: stoneshi-yunify <stoneshi@kubesphere.io>
  • Loading branch information
stoneshi-yunify committed Sep 10, 2024
1 parent e37583a commit 092533c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/webhook/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,22 @@ func (a *Admitter) Admit(ar admissionv1.AdmissionReview) *admissionv1.AdmissionR

raw := ar.Request.Object.Raw
deserializer := codecs.UniversalDeserializer()
pod := &corev1.Pod{}
_, _, err := deserializer.Decode(raw, nil, pod)
podObj := &corev1.Pod{}
obj, _, err := deserializer.Decode(raw, nil, podObj)
if err != nil {
klog.ErrorS(err, "failed to decode raw object")
return toV1AdmissionResponse(err)
}

pod, ok := obj.(*corev1.Pod)
if !ok {
klog.Infof("object %+v is not a pod", obj)
return toV1AdmissionResponseWithPatch(nil)
}

reqInfo := NewReqInfo(pod)

klog.Infof("request info: %v", reqInfo)
klog.Infof("request info: %+v", reqInfo)
return a.Decide(context.Background(), reqInfo)
}

Expand Down

0 comments on commit 092533c

Please sign in to comment.