Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
  • Loading branch information
duckhawk committed Feb 19, 2024
1 parent a232894 commit 28dbb4d
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions images/webhooks/src/validators/pvcMutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ import (
"net/http"
)

type PersistentVolumeClaim struct {
ClaimName string `json:"claimName"`
}

type Volumes struct {
Name string `json:"name"`
PersistentVolumeClaim PersistentVolumeClaim `json:"persistentVolumeClaim"`
}

type PodSpec struct {
SchedulerName string `json:"schedulerName"`
Volumes Volumes `json:"volumes"`
}

type Metadata struct {
Name string `json:"name"`
Labels map[string]string `json:"labels"`
}

type Pod struct {
Spec PodSpec `json:"spec"`
Metadata Metadata `json:"metadata"`
}

func PVCMutation(w http.ResponseWriter, r *http.Request) {
arReview := v1beta1.AdmissionReview{}
if err := json.NewDecoder(r.Body).Decode(&arReview); err != nil {
Expand All @@ -24,14 +48,15 @@ func PVCMutation(w http.ResponseWriter, r *http.Request) {
Allowed: true,
}

var jsonData map[string]interface{}
json.Unmarshal(raw, &jsonData)
//var jsonData map[string]interface{}
var podData Pod
json.Unmarshal(raw, &podData)

klog.Infof("%s", arReview.Request.Operation)
klog.Infof("%s", arReview.Request.Namespace)
klog.Infof("%s", arReview.Request)
klog.Infof("%s", arReview.Request.Object.Raw)
klog.Infof("%s", jsonData["spec"])
klog.Infof("%s", podData)

//if jsonData["provisioner"] == "linstor.csi.linbit.com" {
// if arReview.Request.UserInfo.Username == "system:serviceaccount:d8-sds-drbd:sds-drbd-controller" {
Expand Down

0 comments on commit 28dbb4d

Please sign in to comment.