diff --git a/go.mod b/go.mod index d9a4f94..4c784a9 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/francoispqt/onelog v0.0.0-20190306043706-8c2bb31b10a4 github.com/kubewarden/k8s-objects v1.27.0-kw4 - github.com/kubewarden/policy-sdk-go v0.5.1 + github.com/kubewarden/policy-sdk-go v0.5.2 github.com/wapc/wapc-guest-tinygo v0.3.3 ) diff --git a/go.sum b/go.sum index da54a8a..ef0447e 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,8 @@ github.com/kubewarden/policy-sdk-go v0.5.0 h1:JnSRf5pHjFzTNNp6jJbSP5a4cwzFzkUBjL github.com/kubewarden/policy-sdk-go v0.5.0/go.mod h1:1IZXauwI5iCuOZj7tU58nE/SZFb/HsCmj3ZpDVStVQs= github.com/kubewarden/policy-sdk-go v0.5.1 h1:O2C1NuGtGo5/d7c5iiijV3zheGDfwvBOkphfgl19crE= github.com/kubewarden/policy-sdk-go v0.5.1/go.mod h1:C8sUX4FYhbP69cvQfPLmIvAJhVHQyg1qaq9EynOn8a0= +github.com/kubewarden/policy-sdk-go v0.5.2 h1:GCIXmqNBVG3ADvoH9L9KkBYHM+Npa2G2HZu2Khsyvt8= +github.com/kubewarden/policy-sdk-go v0.5.2/go.mod h1:C8sUX4FYhbP69cvQfPLmIvAJhVHQyg1qaq9EynOn8a0= github.com/kubewarden/strfmt v0.1.3 h1:bb+2rbotioROjCkziSt+hqnHXzOlumN94NxDKdV2kPI= github.com/kubewarden/strfmt v0.1.3/go.mod h1:DXoaaIYwqW1LyyRoMeyxfHUU+VUSTNFdj38juCXfRzs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/vendor/github.com/kubewarden/policy-sdk-go/kubewarden.go b/vendor/github.com/kubewarden/policy-sdk-go/kubewarden.go index 0207547..f66a673 100644 --- a/vendor/github.com/kubewarden/policy-sdk-go/kubewarden.go +++ b/vendor/github.com/kubewarden/policy-sdk-go/kubewarden.go @@ -76,56 +76,56 @@ func MutateRequest(newObject interface{}) ([]byte, error) { // * `pod_spec` - new PodSpec to be set in the response func MutatePodSpecFromRequest(validationRequest protocol.ValidationRequest, podSepc corev1.PodSpec) ([]byte, error) { switch validationRequest.Request.Kind.Kind { - case "apps.v1.Deployment": + case "Deployment": deployment := appsv1.Deployment{} if err := json.Unmarshal(validationRequest.Request.Object, &deployment); err != nil { return nil, err } deployment.Spec.Template.Spec = &podSepc return MutateRequest(deployment) - case "apps.v1.ReplicaSet": + case "ReplicaSet": replicaset := appsv1.ReplicaSet{} if err := json.Unmarshal(validationRequest.Request.Object, &replicaset); err != nil { return nil, err } replicaset.Spec.Template.Spec = &podSepc return MutateRequest(replicaset) - case "apps.v1.StatefulSet": + case "StatefulSet": statefulset := appsv1.StatefulSet{} if err := json.Unmarshal(validationRequest.Request.Object, &statefulset); err != nil { return nil, err } statefulset.Spec.Template.Spec = &podSepc return MutateRequest(statefulset) - case "apps.v1.DaemonSet": + case "DaemonSet": daemonset := appsv1.DaemonSet{} if err := json.Unmarshal(validationRequest.Request.Object, &daemonset); err != nil { return nil, err } daemonset.Spec.Template.Spec = &podSepc return MutateRequest(daemonset) - case "v1.ReplicationController": + case "ReplicationController": replicationController := corev1.ReplicationController{} if err := json.Unmarshal(validationRequest.Request.Object, &replicationController); err != nil { return nil, err } replicationController.Spec.Template.Spec = &podSepc return MutateRequest(replicationController) - case "batch.v1.CronJob": + case "CronJob": cronjob := batchv1.CronJob{} if err := json.Unmarshal(validationRequest.Request.Object, &cronjob); err != nil { return nil, err } cronjob.Spec.JobTemplate.Spec.Template.Spec = &podSepc return MutateRequest(cronjob) - case "batch.v1.Job": + case "Job": job := batchv1.Job{} if err := json.Unmarshal(validationRequest.Request.Object, &job); err != nil { return nil, err } job.Spec.Template.Spec = &podSepc return MutateRequest(job) - case "v1.Pod": + case "Pod": pod := corev1.Pod{} if err := json.Unmarshal(validationRequest.Request.Object, &pod); err != nil { return nil, err @@ -171,49 +171,49 @@ func RejectSettings(message Message) ([]byte, error) { // * `object`: the request to validate func ExtractPodSpecFromObject(object protocol.ValidationRequest) (corev1.PodSpec, error) { switch object.Request.Kind.Kind { - case "apps.v1.Deployment": + case "Deployment": deployment := appsv1.Deployment{} if err := json.Unmarshal(object.Request.Object, &deployment); err != nil { return corev1.PodSpec{}, err } return *deployment.Spec.Template.Spec, nil - case "apps.v1.ReplicaSet": + case "ReplicaSet": replicaset := appsv1.ReplicaSet{} if err := json.Unmarshal(object.Request.Object, &replicaset); err != nil { return corev1.PodSpec{}, err } return *replicaset.Spec.Template.Spec, nil - case "apps.v1.StatefulSet": + case "StatefulSet": statefulset := appsv1.StatefulSet{} if err := json.Unmarshal(object.Request.Object, &statefulset); err != nil { return corev1.PodSpec{}, err } return *statefulset.Spec.Template.Spec, nil - case "apps.v1.DaemonSet": + case "DaemonSet": daemonset := appsv1.DaemonSet{} if err := json.Unmarshal(object.Request.Object, &daemonset); err != nil { return corev1.PodSpec{}, err } return *daemonset.Spec.Template.Spec, nil - case "v1.ReplicationController": + case "ReplicationController": replicationController := corev1.ReplicationController{} if err := json.Unmarshal(object.Request.Object, &replicationController); err != nil { return corev1.PodSpec{}, err } return *replicationController.Spec.Template.Spec, nil - case "batch.v1.CronJob": + case "CronJob": cronjob := batchv1.CronJob{} if err := json.Unmarshal(object.Request.Object, &cronjob); err != nil { return corev1.PodSpec{}, err } return *cronjob.Spec.JobTemplate.Spec.Template.Spec, nil - case "batch.v1.Job": + case "Job": job := batchv1.Job{} if err := json.Unmarshal(object.Request.Object, &job); err != nil { return corev1.PodSpec{}, err } return *job.Spec.Template.Spec, nil - case "v1.Pod": + case "Pod": pod := corev1.Pod{} if err := json.Unmarshal(object.Request.Object, &pod); err != nil { return corev1.PodSpec{}, err diff --git a/vendor/modules.txt b/vendor/modules.txt index 65c1f78..22a1344 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -16,7 +16,7 @@ github.com/kubewarden/k8s-objects/apimachinery/pkg/api/resource github.com/kubewarden/k8s-objects/apimachinery/pkg/apis/meta/v1 github.com/kubewarden/k8s-objects/apimachinery/pkg/runtime/schema github.com/kubewarden/k8s-objects/apimachinery/pkg/util/intstr -# github.com/kubewarden/policy-sdk-go v0.5.1 +# github.com/kubewarden/policy-sdk-go v0.5.2 ## explicit; go 1.20 github.com/kubewarden/policy-sdk-go github.com/kubewarden/policy-sdk-go/constants