diff --git a/go.mod b/go.mod index 04f277b..1854969 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/deckarep/golang-set/v2 v2.6.0 github.com/francoispqt/onelog v0.0.0-20190306043706-8c2bb31b10a4 github.com/kubewarden/gjson v1.7.2 - 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 f563345..1210598 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,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 e5031ef..ee3a5e5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -22,7 +22,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