Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / k8s.io / api / admission / v1beta1 / types.go
1 /*
2 Copyright 2017 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 v1beta1
18
19 import (
20         authenticationv1 "k8s.io/api/authentication/v1"
21         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22         "k8s.io/apimachinery/pkg/runtime"
23         "k8s.io/apimachinery/pkg/types"
24 )
25
26 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
27
28 // AdmissionReview describes an admission review request/response.
29 type AdmissionReview struct {
30         metav1.TypeMeta `json:",inline"`
31         // Request describes the attributes for the admission request.
32         // +optional
33         Request *AdmissionRequest `json:"request,omitempty" protobuf:"bytes,1,opt,name=request"`
34         // Response describes the attributes for the admission response.
35         // +optional
36         Response *AdmissionResponse `json:"response,omitempty" protobuf:"bytes,2,opt,name=response"`
37 }
38
39 // AdmissionRequest describes the admission.Attributes for the admission request.
40 type AdmissionRequest struct {
41         // UID is an identifier for the individual request/response. It allows us to distinguish instances of requests which are
42         // otherwise identical (parallel requests, requests when earlier requests did not modify etc)
43         // The UID is meant to track the round trip (request/response) between the KAS and the WebHook, not the user request.
44         // It is suitable for correlating log entries between the webhook and apiserver, for either auditing or debugging.
45         UID types.UID `json:"uid" protobuf:"bytes,1,opt,name=uid"`
46         // Kind is the type of object being manipulated.  For example: Pod
47         Kind metav1.GroupVersionKind `json:"kind" protobuf:"bytes,2,opt,name=kind"`
48         // Resource is the name of the resource being requested.  This is not the kind.  For example: pods
49         Resource metav1.GroupVersionResource `json:"resource" protobuf:"bytes,3,opt,name=resource"`
50         // SubResource is the name of the subresource being requested.  This is a different resource, scoped to the parent
51         // resource, but it may have a different kind. For instance, /pods has the resource "pods" and the kind "Pod", while
52         // /pods/foo/status has the resource "pods", the sub resource "status", and the kind "Pod" (because status operates on
53         // pods). The binding resource for a pod though may be /pods/foo/binding, which has resource "pods", subresource
54         // "binding", and kind "Binding".
55         // +optional
56         SubResource string `json:"subResource,omitempty" protobuf:"bytes,4,opt,name=subResource"`
57         // Name is the name of the object as presented in the request.  On a CREATE operation, the client may omit name and
58         // rely on the server to generate the name.  If that is the case, this method will return the empty string.
59         // +optional
60         Name string `json:"name,omitempty" protobuf:"bytes,5,opt,name=name"`
61         // Namespace is the namespace associated with the request (if any).
62         // +optional
63         Namespace string `json:"namespace,omitempty" protobuf:"bytes,6,opt,name=namespace"`
64         // Operation is the operation being performed
65         Operation Operation `json:"operation" protobuf:"bytes,7,opt,name=operation"`
66         // UserInfo is information about the requesting user
67         UserInfo authenticationv1.UserInfo `json:"userInfo" protobuf:"bytes,8,opt,name=userInfo"`
68         // Object is the object from the incoming request prior to default values being applied
69         // +optional
70         Object runtime.RawExtension `json:"object,omitempty" protobuf:"bytes,9,opt,name=object"`
71         // OldObject is the existing object. Only populated for UPDATE requests.
72         // +optional
73         OldObject runtime.RawExtension `json:"oldObject,omitempty" protobuf:"bytes,10,opt,name=oldObject"`
74         // DryRun indicates that modifications will definitely not be persisted for this request.
75         // Defaults to false.
76         // +optional
77         DryRun *bool `json:"dryRun,omitempty" protobuf:"varint,11,opt,name=dryRun"`
78 }
79
80 // AdmissionResponse describes an admission response.
81 type AdmissionResponse struct {
82         // UID is an identifier for the individual request/response.
83         // This should be copied over from the corresponding AdmissionRequest.
84         UID types.UID `json:"uid" protobuf:"bytes,1,opt,name=uid"`
85
86         // Allowed indicates whether or not the admission request was permitted.
87         Allowed bool `json:"allowed" protobuf:"varint,2,opt,name=allowed"`
88
89         // Result contains extra details into why an admission request was denied.
90         // This field IS NOT consulted in any way if "Allowed" is "true".
91         // +optional
92         Result *metav1.Status `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
93
94         // The patch body. Currently we only support "JSONPatch" which implements RFC 6902.
95         // +optional
96         Patch []byte `json:"patch,omitempty" protobuf:"bytes,4,opt,name=patch"`
97
98         // The type of Patch. Currently we only allow "JSONPatch".
99         // +optional
100         PatchType *PatchType `json:"patchType,omitempty" protobuf:"bytes,5,opt,name=patchType"`
101
102         // AuditAnnotations is an unstructured key value map set by remote admission controller (e.g. error=image-blacklisted).
103         // MutatingAdmissionWebhook and ValidatingAdmissionWebhook admission controller will prefix the keys with
104         // admission webhook name (e.g. imagepolicy.example.com/error=image-blacklisted). AuditAnnotations will be provided by
105         // the admission webhook to add additional context to the audit log for this request.
106         // +optional
107         AuditAnnotations map[string]string `json:"auditAnnotations,omitempty" protobuf:"bytes,6,opt,name=auditAnnotations"`
108 }
109
110 // PatchType is the type of patch being used to represent the mutated object
111 type PatchType string
112
113 // PatchType constants.
114 const (
115         PatchTypeJSONPatch PatchType = "JSONPatch"
116 )
117
118 // Operation is the type of resource operation being checked for admission control
119 type Operation string
120
121 // Operation constants
122 const (
123         Create  Operation = "CREATE"
124         Update  Operation = "UPDATE"
125         Delete  Operation = "DELETE"
126         Connect Operation = "CONNECT"
127 )