Skip to content

Commit

Permalink
moves admission.v1alpha1.NewAdmissionReview to webhook plugin
Browse files Browse the repository at this point in the history
this is necessary, because the webhook plugin will be moved down to apiserver.
  • Loading branch information
p0lyn0mial committed Oct 4, 2017
1 parent 83d3137 commit 1871712
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 37 deletions.
3 changes: 0 additions & 3 deletions pkg/apis/admission/v1alpha1/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,17 @@ go_library(
name = "go_default_library",
srcs = [
"doc.go",
"helpers.go",
"register.go",
"zz_generated.conversion.go",
"zz_generated.defaults.go",
],
deps = [
"//pkg/apis/admission:go_default_library",
"//vendor/k8s.io/api/admission/v1alpha1:go_default_library",
"//vendor/k8s.io/api/authentication/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_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",
],
)

Expand Down
55 changes: 26 additions & 29 deletions plugin/pkg/admission/webhook/BUILD
Original file line number Diff line number Diff line change
@@ -1,49 +1,24 @@
package(default_visibility = ["//visibility:public"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)

go_test(
name = "go_default_test",
srcs = [
"admission_test.go",
"certs_test.go",
"rules_test.go",
"serviceresolver_test.go",
],
library = ":go_default_library",
deps = [
"//pkg/api:go_default_library",
"//pkg/apis/admission/install:go_default_library",
"//vendor/k8s.io/api/admission/v1alpha1:go_default_library",
"//vendor/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authentication/user:go_default_library",
],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"admission.go",
"admissionreview.go",
"doc.go",
"rules.go",
"serviceresolver.go",
],
visibility = ["//visibility:public"],
deps = [
"//pkg/api:go_default_library",
"//pkg/apis/admission/install:go_default_library",
"//pkg/apis/admission/v1alpha1:go_default_library",
"//pkg/kubeapiserver/admission:go_default_library",
"//pkg/kubeapiserver/admission/configuration:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/api/admission/v1alpha1:go_default_library",
"//vendor/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
"//vendor/k8s.io/api/authentication/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
Expand All @@ -57,6 +32,27 @@ go_library(
],
)

go_test(
name = "go_default_test",
srcs = [
"admission_test.go",
"certs_test.go",
"rules_test.go",
"serviceresolver_test.go",
],
library = ":go_default_library",
deps = [
"//pkg/api:go_default_library",
"//pkg/apis/admission/install:go_default_library",
"//vendor/k8s.io/api/admission/v1alpha1:go_default_library",
"//vendor/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authentication/user:go_default_library",
],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
Expand All @@ -68,4 +64,5 @@ filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
3 changes: 1 addition & 2 deletions plugin/pkg/admission/webhook/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/api"
admissionv1alpha1helper "k8s.io/kubernetes/pkg/apis/admission/v1alpha1"
admissioninit "k8s.io/kubernetes/pkg/kubeapiserver/admission"
"k8s.io/kubernetes/pkg/kubeapiserver/admission/configuration"

Expand Down Expand Up @@ -226,7 +225,7 @@ func (a *GenericAdmissionWebhook) callHook(ctx context.Context, h *v1alpha1.Exte
}

// Make the webhook request
request := admissionv1alpha1helper.NewAdmissionReview(attr)
request := createAdmissionReview(attr)
client, err := a.hookClient(h)
if err != nil {
return &ErrCallingWebhook{WebhookName: h.Name, Reason: err}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
// Package webhook delegates admission checks to dynamically configured webhooks.
package webhook

import (
admissionv1alpha1 "k8s.io/api/admission/v1alpha1"
Expand All @@ -24,8 +25,8 @@ import (
"k8s.io/apiserver/pkg/admission"
)

// NewAdmissionReview returns an AdmissionReview for the provided admission.Attributes
func NewAdmissionReview(attr admission.Attributes) admissionv1alpha1.AdmissionReview {
// createAdmissionReview creates an AdmissionReview for the provided admission.Attributes
func createAdmissionReview(attr admission.Attributes) admissionv1alpha1.AdmissionReview {
gvk := attr.GetKind()
gvr := attr.GetResource()
aUserInfo := attr.GetUserInfo()
Expand Down

0 comments on commit 1871712

Please sign in to comment.