Skip to content

Commit 22fe77a

Browse files
committed
Refactor Validator to remove unused client parameter and update webhook creation accordingly
1 parent 2e8c770 commit 22fe77a

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

internal/hncconfig/validator.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"k8s.io/apimachinery/pkg/runtime/schema"
1414
"k8s.io/apimachinery/pkg/util/validation/field"
1515
ctrl "sigs.k8s.io/controller-runtime"
16-
"sigs.k8s.io/controller-runtime/pkg/client"
1716
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
1817

1918
api "sigs.k8s.io/hierarchical-namespaces/api/v1alpha2"
@@ -38,16 +37,14 @@ type Validator struct {
3837
Log logr.Logger
3938
Forest *forest.Forest
4039
mapper resourceMapper
41-
client client.Client
4240
}
4341

4442
type gvkSet map[schema.GroupVersionKind]api.SynchronizationMode
4543

46-
func NewValidator(forest *forest.Forest, client client.Client) *Validator {
44+
func NewValidator(forest *forest.Forest) *Validator {
4745
return &Validator{
4846
Log: ctrl.Log.WithName("hncconfig").WithName("validate"),
4947
Forest: forest,
50-
client: client,
5148
}
5249
}
5350

internal/hncconfig/validator_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,3 @@ func (f fakeResourceMapper) NamespacedKindFor(gr schema.GroupResource) (schema.G
257257
}
258258
return gr2gvk[gr], nil
259259
}
260-

internal/setup/webhooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func createWebhooks(mgr ctrl.Manager, f *forest.Forest, opts Options) error {
8787
}
8888

8989
// Create webhook for the config
90-
hnconfigValidator := hncconfig.NewValidator(f, mgr.GetClient())
90+
hnconfigValidator := hncconfig.NewValidator(f)
9191
if err := hnconfigValidator.SetupWithManager(mgr); err != nil {
9292
return fmt.Errorf("failed to setup hncconfig validator: %w", err)
9393
}

0 commit comments

Comments
 (0)