Skip to content

Commit e1e25ee

Browse files
joshmerandajoshmeranda
andauthored
[main] register AuditPolicy webhook validation handler (#961)
* register AuditPolicy webhook validation handler * satisfy golangci-lint --------- Co-authored-by: joshmeranda <[email protected]>
1 parent aea1b7c commit e1e25ee

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

pkg/resources/auditlog.cattle.io/v1/auditpolicy/validator.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package v1
1+
package auditpolicy
22

33
import (
44
"errors"
@@ -23,6 +23,10 @@ var gvr = schema.GroupVersionResource{
2323

2424
var _ admission.ValidatingAdmissionHandler = &validator{}
2525

26+
func NewValidator() admission.ValidatingAdmissionHandler {
27+
return &validator{}
28+
}
29+
2630
type validator struct {
2731
}
2832

pkg/resources/auditlog.cattle.io/v1/auditpolicy/validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package v1
1+
package auditpolicy
22

33
import (
44
"testing"

pkg/server/handlers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/rancher/webhook/pkg/clients"
66
v3 "github.com/rancher/webhook/pkg/generated/controllers/management.cattle.io/v3"
77
"github.com/rancher/webhook/pkg/resolvers"
8+
auditpolicy "github.com/rancher/webhook/pkg/resources/auditlog.cattle.io/v1/auditpolicy"
89
"github.com/rancher/webhook/pkg/resources/catalog.cattle.io/v1/clusterrepo"
910
"github.com/rancher/webhook/pkg/resources/cluster.cattle.io/v3/clusterauthtoken"
1011
nshandler "github.com/rancher/webhook/pkg/resources/core/v1/namespace"
@@ -58,6 +59,7 @@ func Validation(clients *clients.Clients) ([]admission.ValidatingAdmissionHandle
5859
machineconfig.NewValidator(),
5960
nshandler.NewValidator(clients.K8s.AuthorizationV1().SubjectAccessReviews()),
6061
clusterrepo.NewValidator(),
62+
auditpolicy.NewValidator(),
6163
}
6264

6365
if clients.MultiClusterManagement {

0 commit comments

Comments
 (0)