12345678910111213141516171819202122232425262728293031323334353637 |
- /*
- Copyright 2019 The Kubernetes Authors.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
- package main
- import (
- "time"
- "k8s.io/api/admission/v1beta1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/klog"
- )
- // alwaysAllowDelayFiveSeconds sleeps for five seconds and allows all requests made to this function.
- func alwaysAllowDelayFiveSeconds(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
- klog.V(2).Info("always-allow-with-delay sleeping for 5 seconds")
- time.Sleep(5 * time.Second)
- klog.V(2).Info("calling always-allow")
- reviewResponse := v1beta1.AdmissionResponse{}
- reviewResponse.Allowed = true
- reviewResponse.Result = &metav1.Status{Message: "this webhook allows all requests"}
- return &reviewResponse
- }
|