Skip to content

Commit

Permalink
refactor: moving to admission/v1 for Kubernetes +1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
prometherion committed May 14, 2021
1 parent 202a18c commit c22cb6c
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pkg/webhook/ingress/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (
capsulewebhook "github.com/clastix/capsule/pkg/webhook"
)

// +kubebuilder:webhook:path=/validating-ingress,mutating=false,failurePolicy=fail,groups=networking.k8s.io;extensions,resources=ingresses,verbs=create;update,versions=v1beta1,name=ingress-v1beta1.capsule.clastix.io
// +kubebuilder:webhook:path=/validating-ingress,mutating=false,failurePolicy=fail,groups=networking.k8s.io,resources=ingresses,verbs=create;update,versions=v1,name=ingress-v1.capsule.clastix.io
// +kubebuilder:webhook:path=/validating-ingress,mutating=false,sideEffects=None,admissionReviewVersions=v1,failurePolicy=fail,groups=networking.k8s.io;extensions,resources=ingresses,verbs=create;update,versions=v1beta1,name=ingress-v1beta1.capsule.clastix.io
// +kubebuilder:webhook:path=/validating-ingress,mutating=false,sideEffects=None,admissionReviewVersions=v1,failurePolicy=fail,groups=networking.k8s.io,resources=ingresses,verbs=create;update,versions=v1,name=ingress-v1.capsule.clastix.io

type webhook struct {
handler capsulewebhook.Handler
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/namespacequota/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
capsulewebhook "github.com/clastix/capsule/pkg/webhook"
)

// +kubebuilder:webhook:path=/validate-v1-namespace-quota,mutating=false,failurePolicy=fail,groups="",resources=namespaces,verbs=create,versions=v1,name=quota.namespace.capsule.clastix.io
// +kubebuilder:webhook:path=/validate-v1-namespace-quota,mutating=false,sideEffects=None,admissionReviewVersions=v1,failurePolicy=fail,groups="",resources=namespaces,verbs=create,versions=v1,name=quota.namespace.capsule.clastix.io

type webhook struct {
handler capsulewebhook.Handler
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/networkpolicies/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
capsulewebhook "github.com/clastix/capsule/pkg/webhook"
)

// +kubebuilder:webhook:path=/validating-v1-network-policy,mutating=false,failurePolicy=fail,groups=networking.k8s.io,resources=networkpolicies,verbs=create;update;delete,versions=v1,name=validating.network-policy.capsule.clastix.io
// +kubebuilder:webhook:path=/validating-v1-network-policy,mutating=false,sideEffects=None,admissionReviewVersions=v1,failurePolicy=fail,groups=networking.k8s.io,resources=networkpolicies,verbs=create;update;delete,versions=v1,name=validating.network-policy.capsule.clastix.io

type webhook struct {
handler capsulewebhook.Handler
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/ownerreference/patching.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
capsulewebhook "github.com/clastix/capsule/pkg/webhook"
)

// +kubebuilder:webhook:path=/mutate-v1-namespace-owner-reference,mutating=true,failurePolicy=fail,groups="",resources=namespaces,verbs=create,versions=v1,name=owner.namespace.capsule.clastix.io
// +kubebuilder:webhook:path=/mutate-v1-namespace-owner-reference,mutating=true,sideEffects=None,admissionReviewVersions=v1,failurePolicy=fail,groups="",resources=namespaces,verbs=create,versions=v1,name=owner.namespace.capsule.clastix.io

type webhook struct {
handler capsulewebhook.Handler
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/pvc/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
capsulewebhook "github.com/clastix/capsule/pkg/webhook"
)

// +kubebuilder:webhook:path=/validating-v1-pvc,mutating=false,failurePolicy=fail,groups="",resources=persistentvolumeclaims,verbs=create,versions=v1,name=pvc.capsule.clastix.io
// +kubebuilder:webhook:path=/validating-v1-pvc,mutating=false,sideEffects=None,admissionReviewVersions=v1,failurePolicy=fail,groups="",resources=persistentvolumeclaims,verbs=create,versions=v1,name=pvc.capsule.clastix.io

type webhook struct {
handler capsulewebhook.Handler
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/registry/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
capsulewebhook "github.com/clastix/capsule/pkg/webhook"
)

// +kubebuilder:webhook:path=/validating-v1-registry,mutating=false,failurePolicy=ignore,groups="",resources=pods,verbs=create,versions=v1,name=pod.capsule.clastix.io
// +kubebuilder:webhook:path=/validating-v1-registry,mutating=false,sideEffects=None,admissionReviewVersions=v1,failurePolicy=ignore,groups="",resources=pods,verbs=create,versions=v1,name=pod.capsule.clastix.io

type webhook struct {
handler capsulewebhook.Handler
Expand Down
8 changes: 4 additions & 4 deletions pkg/webhook/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"context"
"io/ioutil"

admissionv1beta1 "k8s.io/api/admission/v1beta1"
admissionv1 "k8s.io/api/admission/v1"
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand Down Expand Up @@ -53,11 +53,11 @@ type handlerRouter struct {

func (r *handlerRouter) Handle(ctx context.Context, req admission.Request) admission.Response {
switch req.Operation {
case admissionv1beta1.Create:
case admissionv1.Create:
return r.handler.OnCreate(r.client, r.decoder)(ctx, req)
case admissionv1beta1.Update:
case admissionv1.Update:
return r.handler.OnUpdate(r.client, r.decoder)(ctx, req)
case admissionv1beta1.Delete:
case admissionv1.Delete:
return r.handler.OnDelete(r.client, r.decoder)(ctx, req)
default:
return admission.Allowed("")
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/services/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
capsulewebhook "github.com/clastix/capsule/pkg/webhook"
)

// +kubebuilder:webhook:path=/validating-external-service-ips,mutating=false,failurePolicy=fail,groups="",resources=services,verbs=create;update,versions=v1,name=validating-external-service-ips.capsule.clastix.io
// +kubebuilder:webhook:path=/validating-external-service-ips,mutating=false,sideEffects=None,admissionReviewVersions=v1,failurePolicy=fail,groups="",resources=services,verbs=create;update,versions=v1,name=validating-external-service-ips.capsule.clastix.io

type webhook struct {
handler capsulewebhook.Handler
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/tenant/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
capsulewebhook "github.com/clastix/capsule/pkg/webhook"
)

// +kubebuilder:webhook:path=/validating-v1-tenant,mutating=false,failurePolicy=fail,groups="capsule.clastix.io",resources=tenants,verbs=create;update,versions=v1alpha1,name=tenant.capsule.clastix.io
// +kubebuilder:webhook:path=/validating-v1-tenant,mutating=false,sideEffects=None,admissionReviewVersions=v1,failurePolicy=fail,groups="capsule.clastix.io",resources=tenants,verbs=create;update,versions=v1alpha1,name=tenant.capsule.clastix.io

type webhook struct {
handler capsulewebhook.Handler
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/tenantprefix/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
capsulewebhook "github.com/clastix/capsule/pkg/webhook"
)

// +kubebuilder:webhook:path=/validating-v1-namespace-tenant-prefix,mutating=false,failurePolicy=fail,groups="",resources=namespaces,verbs=create,versions=v1,name=prefix.namespace.capsule.clastix.io
// +kubebuilder:webhook:path=/validating-v1-namespace-tenant-prefix,sideEffects=None,admissionReviewVersions=v1,mutating=false,failurePolicy=fail,groups="",resources=namespaces,verbs=create,versions=v1,name=prefix.namespace.capsule.clastix.io

type webhook struct {
handler capsulewebhook.Handler
Expand Down

0 comments on commit c22cb6c

Please sign in to comment.