1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-07 00:17:13 +00:00
kyverno/pkg/webhooks/middleware.go
Yuvraj 277402ba4c
Feature - Add checks for k8s version when Kyverno starts (#831)
* Added k8s version check for mutating and validating'

* version check adde

* middelware added

* formate

* Added timeout flag value to webhook server timeout middelware and refactore kubernetes version check

* Fixed test cases

* Removed log

* Update kubernetes version check

* Added check for mutate and validate

* Skip Validation in handleValidateAdmissionRequest if kubernetes version is below 1.14

* Update return object AdmissionResponse

* fixed condition for skiping mutation

* Handle condition for skip feature in case of kubernetes version 1.14.2
2020-05-18 17:00:52 -07:00

15 lines
337 B
Go

package webhooks
import (
"net/http"
"time"
)
func timeoutHandler(h http.Handler, timeout time.Duration) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var timeoutHandler http.Handler
msg := "ok"
timeoutHandler = http.TimeoutHandler(h, timeout*time.Second, msg)
timeoutHandler.ServeHTTP(w, r)
}
}