Skip to content

Commit

Permalink
remove webhook injections
Browse files Browse the repository at this point in the history
  • Loading branch information
thbkrkr committed May 30, 2023
1 parent cdb91cd commit 2d31fe0
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ type validatingWebhook struct {
managedNamespaces set.StringSet
}

var _ admission.DecoderInjector = &validatingWebhook{}

// InjectDecoder injects the decoder automatically.
func (wh *validatingWebhook) InjectDecoder(d *admission.Decoder) error {
wh.decoder = d
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/common/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ type validatingWebhook struct {
validator admission.Validator
}

var _ admission.DecoderInjector = &validatingWebhook{}

// InjectDecoder injects the decoder automatically.
func (v *validatingWebhook) InjectDecoder(d *admission.Decoder) error {
v.decoder = d
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/common/webhook/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func Test_validatingWebhook_Handle(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := context.Background()
decoder, _ := admission.NewDecoder(k8s.Scheme())
decoder := admission.NewDecoder(k8s.Scheme())
v := &validatingWebhook{
decoder: decoder,
managedNamespaces: tt.fields.managedNamespaces,
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/elasticsearch/validation/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ type validatingWebhook struct {
managedNamespaces set.StringSet
}

var _ admission.DecoderInjector = &validatingWebhook{}

// InjectDecoder injects the decoder automatically.
func (wh *validatingWebhook) InjectDecoder(d *admission.Decoder) error {
wh.decoder = d
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/elasticsearch/validation/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func asJSON(obj interface{}) []byte {
}

func Test_validatingWebhook_Handle(t *testing.T) {
decoder, _ := admission.NewDecoder(k8s.Scheme())
decoder := admission.NewDecoder(k8s.Scheme())
type fields struct {
client k8s.Client
validateStorageClass bool
Expand Down
7 changes: 1 addition & 6 deletions pkg/utils/test/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

controllerscheme "github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/scheme"
ulog "github.com/elastic/cloud-on-k8s/v2/pkg/utils/log"
)

var log = ulog.Log.WithName("test-webhook")

// ValidationWebhookTestCase represents a test case for testing a validation webhook
type ValidationWebhookTestCase struct {
Name string // Name of the test
Expand Down Expand Up @@ -82,9 +79,7 @@ func RunValidationWebhookTests(t *testing.T, gvk metav1.GroupVersionKind, valida
controllerscheme.SetupScheme()
decoder := serializer.NewCodecFactory(clientgoscheme.Scheme).UniversalDeserializer()

webhook := admission.ValidatingWebhookFor(validator)
require.NoError(t, webhook.InjectScheme(clientgoscheme.Scheme))
require.NoError(t, webhook.InjectLogger(log))
webhook := admission.ValidatingWebhookFor(clientgoscheme.Scheme, validator)

server := httptest.NewServer(webhook)
defer server.Close()
Expand Down

0 comments on commit 2d31fe0

Please sign in to comment.