From 8e63473d9e9b2744b1798c08a19f82cdb1a2a17b Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Wed, 23 Aug 2017 20:55:31 +0200 Subject: [PATCH] admission api: cut off api from k8s.io/apiserver This caused an import cycle: api -> apiserver -> api Fixes https://github.com/kubernetes/kubernetes/issues/51212 --- pkg/apis/admission/BUILD | 1 - pkg/apis/admission/types.go | 14 +- pkg/apis/admission/v1alpha1/helpers.go | 2 +- .../v1alpha1/zz_generated.conversion.go | 5 +- staging/src/k8s.io/api/Godeps/Godeps.json | 12 - .../src/k8s.io/api/admission/v1alpha1/BUILD | 1 - .../api/admission/v1alpha1/generated.pb.go | 89 +++--- .../api/admission/v1alpha1/types.generated.go | 298 +++++++++--------- .../k8s.io/api/admission/v1alpha1/types.go | 14 +- 9 files changed, 219 insertions(+), 217 deletions(-) diff --git a/pkg/apis/admission/BUILD b/pkg/apis/admission/BUILD index ea672dbcacc..2756df077cd 100644 --- a/pkg/apis/admission/BUILD +++ b/pkg/apis/admission/BUILD @@ -19,7 +19,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", - "//vendor/k8s.io/apiserver/pkg/admission:go_default_library", ], ) diff --git a/pkg/apis/admission/types.go b/pkg/apis/admission/types.go index 86efca6d7f5..a816fa8d3fa 100644 --- a/pkg/apis/admission/types.go +++ b/pkg/apis/admission/types.go @@ -19,7 +19,6 @@ package admission import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apiserver/pkg/admission" "k8s.io/kubernetes/pkg/apis/authentication" ) @@ -51,7 +50,7 @@ type AdmissionReviewSpec struct { // OldObject is the existing object. Only populated for UPDATE requests. OldObject runtime.Object // Operation is the operation being performed - Operation admission.Operation + Operation Operation // Resource is the name of the resource being requested. This is not the kind. For example: pods Resource metav1.GroupVersionResource // SubResource is the name of the subresource being requested. This is a different resource, scoped to the parent @@ -73,3 +72,14 @@ type AdmissionReviewStatus struct { // +optional Result *metav1.Status } + +// Operation is the type of resource operation being checked for admission control +type Operation string + +// Operation constants +const ( + Create Operation = "CREATE" + Update Operation = "UPDATE" + Delete Operation = "DELETE" + Connect Operation = "CONNECT" +) diff --git a/pkg/apis/admission/v1alpha1/helpers.go b/pkg/apis/admission/v1alpha1/helpers.go index c7a3960b655..ad1e543744c 100644 --- a/pkg/apis/admission/v1alpha1/helpers.go +++ b/pkg/apis/admission/v1alpha1/helpers.go @@ -51,7 +51,7 @@ func NewAdmissionReview(attr admission.Attributes) admissionv1alpha1.AdmissionRe Version: gvr.Version, }, SubResource: attr.GetSubresource(), - Operation: attr.GetOperation(), + Operation: admissionv1alpha1.Operation(attr.GetOperation()), Object: runtime.RawExtension{ Object: attr.GetObject(), }, diff --git a/pkg/apis/admission/v1alpha1/zz_generated.conversion.go b/pkg/apis/admission/v1alpha1/zz_generated.conversion.go index e3047301757..c96eb913882 100644 --- a/pkg/apis/admission/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/admission/v1alpha1/zz_generated.conversion.go @@ -25,7 +25,6 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" - pkg_admission "k8s.io/apiserver/pkg/admission" admission "k8s.io/kubernetes/pkg/apis/admission" unsafe "unsafe" ) @@ -85,7 +84,7 @@ func autoConvert_v1alpha1_AdmissionReviewSpec_To_admission_AdmissionReviewSpec(i if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.OldObject, &out.OldObject, s); err != nil { return err } - out.Operation = pkg_admission.Operation(in.Operation) + out.Operation = admission.Operation(in.Operation) out.Name = in.Name out.Namespace = in.Namespace out.Resource = in.Resource @@ -112,7 +111,7 @@ func autoConvert_admission_AdmissionReviewSpec_To_v1alpha1_AdmissionReviewSpec(i if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.OldObject, &out.OldObject, s); err != nil { return err } - out.Operation = pkg_admission.Operation(in.Operation) + out.Operation = v1alpha1.Operation(in.Operation) out.Resource = in.Resource out.SubResource = in.SubResource // TODO: Inefficient conversion - can we improve it? diff --git a/staging/src/k8s.io/api/Godeps/Godeps.json b/staging/src/k8s.io/api/Godeps/Godeps.json index babb6ba48c0..b4ec17ea4fb 100644 --- a/staging/src/k8s.io/api/Godeps/Godeps.json +++ b/staging/src/k8s.io/api/Godeps/Godeps.json @@ -14,10 +14,6 @@ "ImportPath": "github.com/PuerkitoBio/urlesc", "Rev": "5bd2802263f21d8788851d5305584c82a5c75d7e" }, - { - "ImportPath": "github.com/davecgh/go-spew/spew", - "Rev": "782f4967f2dc4564575ca782fe2d04090b5faca8" - }, { "ImportPath": "github.com/emicklei/go-restful", "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" @@ -26,10 +22,6 @@ "ImportPath": "github.com/emicklei/go-restful/log", "Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46" }, - { - "ImportPath": "github.com/ghodss/yaml", - "Rev": "73d445a93680fa1a78ae23a5839bad48f32ba1ee" - }, { "ImportPath": "github.com/go-openapi/jsonpointer", "Rev": "46af16f9f7b149af66e5d1bd010e3574dc06de98" @@ -145,10 +137,6 @@ { "ImportPath": "gopkg.in/inf.v0", "Rev": "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4" - }, - { - "ImportPath": "gopkg.in/yaml.v2", - "Rev": "53feefa2559fb8dfa8d81baad31be332c97d6c77" } ] } diff --git a/staging/src/k8s.io/api/admission/v1alpha1/BUILD b/staging/src/k8s.io/api/admission/v1alpha1/BUILD index 389b56c3a9d..714b425a4a1 100644 --- a/staging/src/k8s.io/api/admission/v1alpha1/BUILD +++ b/staging/src/k8s.io/api/admission/v1alpha1/BUILD @@ -25,7 +25,6 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", - "//vendor/k8s.io/apiserver/pkg/admission:go_default_library", ], ) diff --git a/staging/src/k8s.io/api/admission/v1alpha1/generated.pb.go b/staging/src/k8s.io/api/admission/v1alpha1/generated.pb.go index 9d3ea2eb583..03fa1f6be8d 100644 --- a/staging/src/k8s.io/api/admission/v1alpha1/generated.pb.go +++ b/staging/src/k8s.io/api/admission/v1alpha1/generated.pb.go @@ -37,8 +37,6 @@ import math "math" import k8s_io_apimachinery_pkg_apis_meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" -import k8s_io_apiserver_pkg_admission "k8s.io/apiserver/pkg/admission" - import strings "strings" import reflect "reflect" @@ -605,7 +603,7 @@ func (m *AdmissionReviewSpec) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Operation = k8s_io_apiserver_pkg_admission.Operation(dAtA[iNdEx:postIndex]) + m.Operation = Operation(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { @@ -988,47 +986,46 @@ func init() { } var fileDescriptorGenerated = []byte{ - // 663 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x4b, 0x1c, 0x49, - 0x14, 0xc7, 0xa7, 0x77, 0xc7, 0x71, 0xa6, 0x5c, 0xd6, 0xdd, 0x92, 0x85, 0x46, 0xd8, 0x56, 0x3c, - 0x2c, 0x2e, 0x68, 0x35, 0x1a, 0x23, 0x21, 0x90, 0x83, 0x03, 0x49, 0x08, 0x01, 0x0d, 0xa5, 0x86, - 0x90, 0x84, 0x40, 0x4d, 0xcf, 0x73, 0xa6, 0x32, 0xd3, 0x55, 0x4d, 0x55, 0xf5, 0x98, 0xdc, 0xf2, - 0x27, 0xe4, 0x90, 0x7f, 0x29, 0xe0, 0x25, 0xe0, 0xd1, 0x93, 0xc4, 0xc9, 0x7f, 0x91, 0x53, 0xe8, - 0xea, 0xea, 0x6e, 0x1d, 0x35, 0x89, 0x39, 0xcd, 0xbc, 0x1f, 0xdf, 0x4f, 0xbd, 0x7a, 0xf5, 0x5e, - 0xa3, 0x07, 0x83, 0x3b, 0x9a, 0x70, 0x19, 0x0e, 0xd2, 0x0e, 0x28, 0x01, 0x06, 0x74, 0x38, 0x02, - 0xd1, 0x95, 0x2a, 0x74, 0x01, 0x96, 0xf0, 0x90, 0x75, 0x63, 0xae, 0x35, 0x97, 0x22, 0x1c, 0xad, - 0xb1, 0x61, 0xd2, 0x67, 0x6b, 0x61, 0x0f, 0x04, 0x28, 0x66, 0xa0, 0x4b, 0x12, 0x25, 0x8d, 0xc4, - 0xff, 0xe6, 0xe9, 0x84, 0x25, 0x9c, 0x94, 0xe9, 0xa4, 0x48, 0x9f, 0x5f, 0xed, 0x71, 0xd3, 0x4f, - 0x3b, 0x24, 0x92, 0x71, 0xd8, 0x93, 0x3d, 0x19, 0x5a, 0x55, 0x27, 0x3d, 0xb0, 0x96, 0x35, 0xec, - 0xbf, 0x9c, 0x36, 0xbf, 0x72, 0xfe, 0xf0, 0xd4, 0xf4, 0x41, 0x18, 0x1e, 0x31, 0x93, 0x57, 0x30, - 0x79, 0xf6, 0xfc, 0x46, 0x95, 0x1d, 0xb3, 0xa8, 0xcf, 0x05, 0xa8, 0xb7, 0x61, 0x32, 0xe8, 0x65, - 0x0e, 0x1d, 0xc6, 0x60, 0xd8, 0x55, 0xaa, 0xf0, 0x3a, 0x95, 0x4a, 0x85, 0xe1, 0x31, 0x5c, 0x12, - 0x6c, 0xfe, 0x48, 0xa0, 0xa3, 0x3e, 0xc4, 0xec, 0x92, 0xee, 0xd6, 0x75, 0xba, 0xd4, 0xf0, 0x61, - 0xc8, 0x85, 0xd1, 0x46, 0x4d, 0x8a, 0x96, 0x3e, 0x7a, 0x68, 0x76, 0xab, 0xe8, 0x23, 0x85, 0x11, - 0x87, 0x43, 0xbc, 0x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, - 0xbb, 0x71, 0xe0, 0x1d, 0x8d, 0x03, 0xef, 0x78, 0x1c, 0x78, 0x27, 0xe3, 0xc0, 0xfb, 0x3c, 0x0e, - 0xbc, 0xf7, 0x5f, 0x82, 0xda, 0xf3, 0x66, 0xb1, 0xc4, 0xdf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x42, - 0x53, 0xac, 0x65, 0xf7, 0x05, 0x00, 0x00, + // 645 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x4f, 0x13, 0x41, + 0x14, 0xc7, 0xbb, 0x5a, 0x4a, 0x3b, 0x18, 0xd1, 0x21, 0x26, 0x1b, 0x12, 0x17, 0xc2, 0xc1, 0x60, + 0x02, 0xb3, 0x01, 0x91, 0x18, 0xe3, 0x85, 0x26, 0x6a, 0x8c, 0x09, 0x98, 0x01, 0x8c, 0x31, 0xc6, + 0x64, 0xba, 0x7d, 0xb4, 0x63, 0xbb, 0x33, 0x9b, 0x9d, 0xd9, 0xa2, 0x37, 0xff, 0x04, 0x0f, 0xfe, + 0x1d, 0xfe, 0x17, 0x26, 0x1c, 0x39, 0x72, 0x22, 0x52, 0xff, 0x0b, 0x4f, 0x66, 0x67, 0x67, 0x77, + 0x4b, 0xa1, 0x2a, 0x9e, 0xda, 0xf7, 0xe3, 0xfb, 0x99, 0xf7, 0xde, 0xbc, 0x59, 0xf4, 0xac, 0xf7, + 0x48, 0x11, 0x2e, 0xfd, 0x5e, 0xd2, 0x82, 0x58, 0x80, 0x06, 0xe5, 0x0f, 0x40, 0xb4, 0x65, 0xec, + 0xdb, 0x00, 0x8b, 0xb8, 0xcf, 0xda, 0x21, 0x57, 0x8a, 0x4b, 0xe1, 0x0f, 0xd6, 0x58, 0x3f, 0xea, + 0xb2, 0x35, 0xbf, 0x03, 0x02, 0x62, 0xa6, 0xa1, 0x4d, 0xa2, 0x58, 0x6a, 0x89, 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 0x6a, 0x8f, 0x8b, 0xb6, 0xed, 0x65, 0x73, 0xe4, 0xcc, 0x62, 0x46, 0x24, 0xea, + 0x75, 0x52, 0x87, 0x22, 0xe9, 0x15, 0x92, 0xc1, 0x1a, 0x79, 0x1e, 0xcb, 0x24, 0x7a, 0x0d, 0x71, + 0xca, 0x7a, 0xc9, 0x45, 0xbb, 0xec, 0x27, 0xb5, 0xa8, 0x21, 0xe2, 0x7d, 0x54, 0x93, 0xad, 0x0f, + 0x10, 0x68, 0xdb, 0xcf, 0xea, 0x44, 0xb6, 0xbd, 0x37, 0x42, 0xd9, 0xe1, 0xd3, 0x8f, 0x1a, 0x44, + 0x8a, 0x2d, 0x1b, 0xd9, 0x31, 0x10, 0x6a, 0x61, 0xf8, 0x3d, 0x6a, 0xc8, 0x7e, 0x3b, 0x73, 0xba, + 0xd7, 0xff, 0x87, 0x7c, 0xdb, 0x92, 0x1b, 0x3b, 0x39, 0x87, 0x96, 0x48, 0xfc, 0x04, 0x35, 0x64, + 0x94, 0xae, 0x00, 0x97, 0xc2, 0xad, 0x2e, 0x3a, 0xcb, 0x8d, 0xa6, 0x57, 0x08, 0xf2, 0xc0, 0xaf, + 0x51, 0x83, 0x96, 0x02, 0xbc, 0x88, 0xaa, 0x82, 0x85, 0xe0, 0x4e, 0x19, 0x61, 0x31, 0x96, 0x6d, + 0x16, 0x02, 0x35, 0x11, 0xec, 0xa3, 0x46, 0xfa, 0xab, 0x22, 0x16, 0x80, 0x5b, 0x33, 0x69, 0x45, + 0x41, 0xdb, 0x79, 0x80, 0x96, 0x39, 0xb8, 0x8b, 0xea, 0x31, 0x28, 0x99, 0xc4, 0x01, 0xb8, 0xd3, + 0xa6, 0xdf, 0xc7, 0x57, 0xbf, 0x25, 0x6a, 0x09, 0xcd, 0x5b, 0xf6, 0xac, 0x7a, 0xee, 0xa1, 0x05, + 0x1d, 0x3f, 0x44, 0x33, 0x2a, 0x69, 0xe5, 0x01, 0xb7, 0x6e, 0x8a, 0x9b, 0xb3, 0x82, 0x99, 0xdd, + 0x32, 0x44, 0x47, 0xf3, 0xf0, 0x1e, 0xaa, 0x27, 0x0a, 0xe2, 0x17, 0xe2, 0x40, 0xba, 0x0d, 0x53, + 0xe0, 0xbd, 0x73, 0xab, 0x7b, 0xee, 0xbb, 0x91, 0x16, 0xb6, 0x6f, 0xb3, 0xcb, 0x62, 0x72, 0x0f, + 0x2d, 0x48, 0x4b, 0x5f, 0x1d, 0x74, 0xe7, 0xd2, 0x15, 0xc7, 0xf7, 0xd1, 0x34, 0xeb, 0xf7, 0xe5, + 0x21, 0x64, 0x5b, 0x5b, 0x6f, 0xce, 0x5a, 0xcc, 0xf4, 0x56, 0xe6, 0xa6, 0x79, 0x1c, 0xbf, 0x1a, + 0x7b, 0x53, 0x2b, 0xff, 0x36, 0x39, 0xfb, 0x96, 0x50, 0xba, 0x7e, 0x14, 0x54, 0xd2, 0xd7, 0xf9, + 0x3b, 0x6a, 0x92, 0xa3, 0x33, 0xaf, 0x72, 0x7c, 0xe6, 0x55, 0x4e, 0xce, 0xbc, 0xca, 0xe7, 0xa1, + 0xe7, 0x1c, 0x0d, 0x3d, 0xe7, 0x78, 0xe8, 0x39, 0x27, 0x43, 0xcf, 0xf9, 0x31, 0xf4, 0x9c, 0x2f, + 0x3f, 0xbd, 0xca, 0xdb, 0x7a, 0xfe, 0x4a, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xa0, 0x57, 0xa7, + 0x50, 0xd8, 0x05, 0x00, 0x00, } diff --git a/staging/src/k8s.io/api/admission/v1alpha1/types.generated.go b/staging/src/k8s.io/api/admission/v1alpha1/types.generated.go index 6ca9a63bc42..ee49a96c39f 100644 --- a/staging/src/k8s.io/api/admission/v1alpha1/types.generated.go +++ b/staging/src/k8s.io/api/admission/v1alpha1/types.generated.go @@ -25,11 +25,10 @@ import ( "errors" "fmt" codec1978 "github.com/ugorji/go/codec" - pkg4_v1 "k8s.io/api/authentication/v1" + pkg3_v1 "k8s.io/api/authentication/v1" pkg1_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" pkg2_runtime "k8s.io/apimachinery/pkg/runtime" - pkg5_types "k8s.io/apimachinery/pkg/types" - pkg3_admission "k8s.io/apiserver/pkg/admission" + pkg4_types "k8s.io/apimachinery/pkg/types" "reflect" "runtime" ) @@ -64,12 +63,11 @@ func init() { panic(err) } if false { // reference the types, but skip this branch at build/run time - var v0 pkg4_v1.UserInfo + var v0 pkg3_v1.UserInfo var v1 pkg1_v1.TypeMeta var v2 pkg2_runtime.RawExtension - var v3 pkg5_types.UID - var v4 pkg3_admission.Operation - _, _, _, _, _ = v0, v1, v2, v3, v4 + var v3 pkg4_types.UID + _, _, _, _ = v0, v1, v2, v3 } } @@ -535,13 +533,7 @@ func (x *AdmissionReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) if yyq2[3] { - yym19 := z.EncBinary() - _ = yym19 - if false { - } else if z.HasExtensions() && z.EncExt(x.Operation) { - } else { - r.EncodeString(codecSelferC_UTF81234, string(x.Operation)) - } + x.Operation.CodecEncodeSelf(e) } else { r.EncodeString(codecSelferC_UTF81234, "") } @@ -550,13 +542,7 @@ func (x *AdmissionReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("operation")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym20 := z.EncBinary() - _ = yym20 - if false { - } else if z.HasExtensions() && z.EncExt(x.Operation) { - } else { - r.EncodeString(codecSelferC_UTF81234, string(x.Operation)) - } + x.Operation.CodecEncodeSelf(e) } } if yyr2 || yy2arr2 { @@ -789,69 +775,63 @@ func (x *AdmissionReviewSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder x.Operation = "" } else { yyv10 := &x.Operation - yym11 := z.DecBinary() - _ = yym11 - if false { - } else if z.HasExtensions() && z.DecExt(yyv10) { - } else { - *((*string)(yyv10)) = r.DecodeString() - } + yyv10.CodecDecodeSelf(d) } case "name": if r.TryDecodeAsNil() { x.Name = "" } else { - yyv12 := &x.Name - yym13 := z.DecBinary() - _ = yym13 + yyv11 := &x.Name + yym12 := z.DecBinary() + _ = yym12 if false { } else { - *((*string)(yyv12)) = r.DecodeString() + *((*string)(yyv11)) = r.DecodeString() } } case "namespace": if r.TryDecodeAsNil() { x.Namespace = "" } else { - yyv14 := &x.Namespace - yym15 := z.DecBinary() - _ = yym15 + yyv13 := &x.Namespace + yym14 := z.DecBinary() + _ = yym14 if false { } else { - *((*string)(yyv14)) = r.DecodeString() + *((*string)(yyv13)) = r.DecodeString() } } case "resource": if r.TryDecodeAsNil() { x.Resource = pkg1_v1.GroupVersionResource{} } else { - yyv16 := &x.Resource - yym17 := z.DecBinary() - _ = yym17 + yyv15 := &x.Resource + yym16 := z.DecBinary() + _ = yym16 if false { - } else if z.HasExtensions() && z.DecExt(yyv16) { + } else if z.HasExtensions() && z.DecExt(yyv15) { } else { - z.DecFallback(yyv16, false) + z.DecFallback(yyv15, false) } } case "subResource": if r.TryDecodeAsNil() { x.SubResource = "" } else { - yyv18 := &x.SubResource - yym19 := z.DecBinary() - _ = yym19 + yyv17 := &x.SubResource + yym18 := z.DecBinary() + _ = yym18 if false { } else { - *((*string)(yyv18)) = r.DecodeString() + *((*string)(yyv17)) = r.DecodeString() } } case "userInfo": if r.TryDecodeAsNil() { - x.UserInfo = pkg4_v1.UserInfo{} + x.UserInfo = pkg3_v1.UserInfo{} } else { - yyv20 := &x.UserInfo - yyv20.CodecDecodeSelf(d) + yyv19 := &x.UserInfo + yyv19.CodecDecodeSelf(d) } default: z.DecStructFieldNotFound(-1, yys3) @@ -864,16 +844,16 @@ func (x *AdmissionReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decod var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj21 int - var yyb21 bool - var yyhl21 bool = l >= 0 - yyj21++ - if yyhl21 { - yyb21 = yyj21 > l + var yyj20 int + var yyb20 bool + var yyhl20 bool = l >= 0 + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l } else { - yyb21 = r.CheckBreak() + yyb20 = r.CheckBreak() } - if yyb21 { + if yyb20 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -881,22 +861,22 @@ func (x *AdmissionReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decod if r.TryDecodeAsNil() { x.Kind = pkg1_v1.GroupVersionKind{} } else { - yyv22 := &x.Kind - yym23 := z.DecBinary() - _ = yym23 + yyv21 := &x.Kind + yym22 := z.DecBinary() + _ = yym22 if false { - } else if z.HasExtensions() && z.DecExt(yyv22) { + } else if z.HasExtensions() && z.DecExt(yyv21) { } else { - z.DecFallback(yyv22, false) + z.DecFallback(yyv21, false) } } - yyj21++ - if yyhl21 { - yyb21 = yyj21 > l + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l } else { - yyb21 = r.CheckBreak() + yyb20 = r.CheckBreak() } - if yyb21 { + if yyb20 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -904,24 +884,24 @@ func (x *AdmissionReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decod if r.TryDecodeAsNil() { x.Object = pkg2_runtime.RawExtension{} } else { - yyv24 := &x.Object - yym25 := z.DecBinary() - _ = yym25 + yyv23 := &x.Object + yym24 := z.DecBinary() + _ = yym24 if false { - } else if z.HasExtensions() && z.DecExt(yyv24) { - } else if !yym25 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv24) + } else if z.HasExtensions() && z.DecExt(yyv23) { + } else if !yym24 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv23) } else { - z.DecFallback(yyv24, false) + z.DecFallback(yyv23, false) } } - yyj21++ - if yyhl21 { - yyb21 = yyj21 > l + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l } else { - yyb21 = r.CheckBreak() + yyb20 = r.CheckBreak() } - if yyb21 { + if yyb20 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -929,24 +909,24 @@ func (x *AdmissionReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decod if r.TryDecodeAsNil() { x.OldObject = pkg2_runtime.RawExtension{} } else { - yyv26 := &x.OldObject - yym27 := z.DecBinary() - _ = yym27 + yyv25 := &x.OldObject + yym26 := z.DecBinary() + _ = yym26 if false { - } else if z.HasExtensions() && z.DecExt(yyv26) { - } else if !yym27 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv26) + } else if z.HasExtensions() && z.DecExt(yyv25) { + } else if !yym26 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv25) } else { - z.DecFallback(yyv26, false) + z.DecFallback(yyv25, false) } } - yyj21++ - if yyhl21 { - yyb21 = yyj21 > l + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l } else { - yyb21 = r.CheckBreak() + yyb20 = r.CheckBreak() } - if yyb21 { + if yyb20 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -954,22 +934,16 @@ func (x *AdmissionReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decod if r.TryDecodeAsNil() { x.Operation = "" } else { - yyv28 := &x.Operation - yym29 := z.DecBinary() - _ = yym29 - if false { - } else if z.HasExtensions() && z.DecExt(yyv28) { - } else { - *((*string)(yyv28)) = r.DecodeString() - } + yyv27 := &x.Operation + yyv27.CodecDecodeSelf(d) } - yyj21++ - if yyhl21 { - yyb21 = yyj21 > l + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l } else { - yyb21 = r.CheckBreak() + yyb20 = r.CheckBreak() } - if yyb21 { + if yyb20 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -977,21 +951,21 @@ func (x *AdmissionReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decod if r.TryDecodeAsNil() { x.Name = "" } else { - yyv30 := &x.Name - yym31 := z.DecBinary() - _ = yym31 + yyv28 := &x.Name + yym29 := z.DecBinary() + _ = yym29 if false { } else { - *((*string)(yyv30)) = r.DecodeString() + *((*string)(yyv28)) = r.DecodeString() } } - yyj21++ - if yyhl21 { - yyb21 = yyj21 > l + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l } else { - yyb21 = r.CheckBreak() + yyb20 = r.CheckBreak() } - if yyb21 { + if yyb20 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -999,21 +973,21 @@ func (x *AdmissionReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decod if r.TryDecodeAsNil() { x.Namespace = "" } else { - yyv32 := &x.Namespace - yym33 := z.DecBinary() - _ = yym33 + yyv30 := &x.Namespace + yym31 := z.DecBinary() + _ = yym31 if false { } else { - *((*string)(yyv32)) = r.DecodeString() + *((*string)(yyv30)) = r.DecodeString() } } - yyj21++ - if yyhl21 { - yyb21 = yyj21 > l + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l } else { - yyb21 = r.CheckBreak() + yyb20 = r.CheckBreak() } - if yyb21 { + if yyb20 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -1021,22 +995,22 @@ func (x *AdmissionReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decod if r.TryDecodeAsNil() { x.Resource = pkg1_v1.GroupVersionResource{} } else { - yyv34 := &x.Resource - yym35 := z.DecBinary() - _ = yym35 + yyv32 := &x.Resource + yym33 := z.DecBinary() + _ = yym33 if false { - } else if z.HasExtensions() && z.DecExt(yyv34) { + } else if z.HasExtensions() && z.DecExt(yyv32) { } else { - z.DecFallback(yyv34, false) + z.DecFallback(yyv32, false) } } - yyj21++ - if yyhl21 { - yyb21 = yyj21 > l + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l } else { - yyb21 = r.CheckBreak() + yyb20 = r.CheckBreak() } - if yyb21 { + if yyb20 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -1044,43 +1018,43 @@ func (x *AdmissionReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decod if r.TryDecodeAsNil() { x.SubResource = "" } else { - yyv36 := &x.SubResource - yym37 := z.DecBinary() - _ = yym37 + yyv34 := &x.SubResource + yym35 := z.DecBinary() + _ = yym35 if false { } else { - *((*string)(yyv36)) = r.DecodeString() + *((*string)(yyv34)) = r.DecodeString() } } - yyj21++ - if yyhl21 { - yyb21 = yyj21 > l + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l } else { - yyb21 = r.CheckBreak() + yyb20 = r.CheckBreak() } - if yyb21 { + if yyb20 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } z.DecSendContainerState(codecSelfer_containerArrayElem1234) if r.TryDecodeAsNil() { - x.UserInfo = pkg4_v1.UserInfo{} + x.UserInfo = pkg3_v1.UserInfo{} } else { - yyv38 := &x.UserInfo - yyv38.CodecDecodeSelf(d) + yyv36 := &x.UserInfo + yyv36.CodecDecodeSelf(d) } for { - yyj21++ - if yyhl21 { - yyb21 = yyj21 > l + yyj20++ + if yyhl20 { + yyb20 = yyj20 > l } else { - yyb21 = r.CheckBreak() + yyb20 = r.CheckBreak() } - if yyb21 { + if yyb20 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj21-1, "") + z.DecStructFieldNotFound(yyj20-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -1338,3 +1312,29 @@ func (x *AdmissionReviewStatus) codecDecodeSelfFromArray(l int, d *codec1978.Dec } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } + +func (x Operation) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x)) + } +} + +func (x *Operation) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym1 := z.DecBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + *((*string)(x)) = r.DecodeString() + } +} diff --git a/staging/src/k8s.io/api/admission/v1alpha1/types.go b/staging/src/k8s.io/api/admission/v1alpha1/types.go index c727f05292b..5defadca6bd 100644 --- a/staging/src/k8s.io/api/admission/v1alpha1/types.go +++ b/staging/src/k8s.io/api/admission/v1alpha1/types.go @@ -20,7 +20,6 @@ import ( authenticationv1 "k8s.io/api/authentication/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apiserver/pkg/admission" ) // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -48,7 +47,7 @@ type AdmissionReviewSpec struct { // +optional OldObject runtime.RawExtension `json:"oldObject,omitempty" protobuf:"bytes,3,opt,name=oldObject"` // Operation is the operation being performed - Operation admission.Operation `json:"operation,omitempty" protobuf:"bytes,4,opt,name=operation"` + Operation Operation `json:"operation,omitempty" protobuf:"bytes,4,opt,name=operation"` // Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and // rely on the server to generate the name. If that is the case, this method will return the empty string. // +optional @@ -78,3 +77,14 @@ type AdmissionReviewStatus struct { // +optional Result *metav1.Status `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"` } + +// Operation is the type of resource operation being checked for admission control +type Operation string + +// Operation constants +const ( + Create Operation = "CREATE" + Update Operation = "UPDATE" + Delete Operation = "DELETE" + Connect Operation = "CONNECT" +)