Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / sigs.k8s.io / controller-runtime / pkg / webhook / admission / types / types.go
1 /*
2 Copyright 2018 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package types
18
19 import (
20         "github.com/appscode/jsonpatch"
21
22         admissionv1beta1 "k8s.io/api/admission/v1beta1"
23         "k8s.io/apimachinery/pkg/runtime"
24 )
25
26 // Request is the input of Handler
27 type Request struct {
28         AdmissionRequest *admissionv1beta1.AdmissionRequest
29 }
30
31 // Response is the output of admission.Handler
32 type Response struct {
33         // Patches are the JSON patches for mutating webhooks.
34         // Using this instead of setting Response.Patch to minimize the overhead of serialization and deserialization.
35         Patches []jsonpatch.JsonPatchOperation
36         // Response is the admission response. Don't set the Patch field in it.
37         Response *admissionv1beta1.AdmissionResponse
38 }
39
40 // Decoder is used to decode AdmissionRequest.
41 type Decoder interface {
42         // Decode decodes the raw byte object from the AdmissionRequest to the passed-in runtime.Object.
43         Decode(Request, runtime.Object) error
44 }