From e1ccfa4e7deddfae48c1db4162a533409d194d68 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Mon, 30 Jul 2018 18:35:51 -0700 Subject: [PATCH 1/2] Remove rest.ConnectRequest. Make apiserver pass connectRequest.Options directly to the admission layer. All the information in rest.ConnectRequest is present in admission attributes. Kubernetes-commit: 355691d310803ea3a0cd8ff284a39ead38857602 --- pkg/endpoints/handlers/rest.go | 9 +--- pkg/registry/rest/rest.go | 16 ------- pkg/registry/rest/zz_generated.deepcopy.go | 52 ---------------------- 3 files changed, 2 insertions(+), 75 deletions(-) delete mode 100644 pkg/registry/rest/zz_generated.deepcopy.go diff --git a/pkg/endpoints/handlers/rest.go b/pkg/endpoints/handlers/rest.go index 09a03d4c1..8b3ca9d62 100644 --- a/pkg/endpoints/handlers/rest.go +++ b/pkg/endpoints/handlers/rest.go @@ -120,22 +120,17 @@ func ConnectResource(connecter rest.Connecter, scope RequestScope, admit admissi return } if admit != nil && admit.Handles(admission.Connect) { - connectRequest := &rest.ConnectRequest{ - Name: name, - Options: opts, - ResourcePath: restPath, - } userInfo, _ := request.UserFrom(ctx) // TODO: remove the mutating admission here as soon as we have ported all plugin that handle CONNECT if mutatingAdmission, ok := admit.(admission.MutationInterface); ok { - err = mutatingAdmission.Admit(admission.NewAttributesRecord(connectRequest, nil, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Connect, false, userInfo)) + err = mutatingAdmission.Admit(admission.NewAttributesRecord(opts, nil, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Connect, false, userInfo)) if err != nil { scope.err(err, w, req) return } } if validatingAdmission, ok := admit.(admission.ValidationInterface); ok { - err = validatingAdmission.Validate(admission.NewAttributesRecord(connectRequest, nil, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Connect, false, userInfo)) + err = validatingAdmission.Validate(admission.NewAttributesRecord(opts, nil, scope.Kind, namespace, name, scope.Resource, scope.Subresource, admission.Connect, false, userInfo)) if err != nil { scope.err(err, w, req) return diff --git a/pkg/registry/rest/rest.go b/pkg/registry/rest/rest.go index d3d1b2f8b..0c67ce3e3 100644 --- a/pkg/registry/rest/rest.go +++ b/pkg/registry/rest/rest.go @@ -334,19 +334,3 @@ type StorageMetadata interface { // it is not nil. Only the type of the return object matters, the value will be ignored. ProducesObject(verb string) interface{} } - -// +k8s:deepcopy-gen=true -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// ConnectRequest is an object passed to admission control for Connect operations -type ConnectRequest struct { - // Name is the name of the object on which the connect request was made - Name string - - // Options is the options object passed to the connect request. See the NewConnectOptions method on Connecter - Options runtime.Object - - // ResourcePath is the path for the resource in the REST server (ie. "pods/proxy") - ResourcePath string -} - -func (obj *ConnectRequest) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind } diff --git a/pkg/registry/rest/zz_generated.deepcopy.go b/pkg/registry/rest/zz_generated.deepcopy.go deleted file mode 100644 index ef8c371ba..000000000 --- a/pkg/registry/rest/zz_generated.deepcopy.go +++ /dev/null @@ -1,52 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright 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. -*/ - -// Code generated by deepcopy-gen. DO NOT EDIT. - -package rest - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConnectRequest) DeepCopyInto(out *ConnectRequest) { - *out = *in - if in.Options != nil { - out.Options = in.Options.DeepCopyObject() - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConnectRequest. -func (in *ConnectRequest) DeepCopy() *ConnectRequest { - if in == nil { - return nil - } - out := new(ConnectRequest) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ConnectRequest) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} From 15ecce8b12be9414f95df77f639c3c6d6f624298 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Tue, 31 Jul 2018 16:27:23 -0700 Subject: [PATCH 2/2] generated Kubernetes-commit: d89c8dd8c0bf1a7be84f50d1a0b9a9a47b6b5d69