Skip to content

Commit

Permalink
feat: add mutate webhook config create
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Sep 4, 2024
1 parent 5042e5c commit 32aec04
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/webhook-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ func WriteFile(filepath string, sCert *bytes.Buffer) error {
return nil
}

//+kubebuilder:rbac:groups=admissionregistration.k8s.io,resources=mutatingwebhookconfigurations,verbs=get;list;watch;create;update;patch;delete

func createMutationConfig(caCert *bytes.Buffer) {
var (
webhookNamespace, _ = os.LookupEnv("WEBHOOK_NAMESPACE")
Expand Down
12 changes: 12 additions & 0 deletions config/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ kind: ClusterRole
metadata:
name: webhook-role
rules:
- apiGroups:
- admissionregistration.k8s.io
resources:
- mutatingwebhookconfigurations
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- krm.kcl.dev
resources:
Expand Down
12 changes: 12 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ kind: ClusterRole
metadata:
name: webhook-role
rules:
- apiGroups:
- admissionregistration.k8s.io
resources:
- mutatingwebhookconfigurations
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- krm.kcl.dev
resources:
Expand Down
1 change: 1 addition & 0 deletions pkg/webhook/handler/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
//+kubebuilder:rbac:groups=krm.kcl.dev,resources=kclruns,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=krm.kcl.dev,resources=kclruns/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=krm.kcl.dev,resources=kclruns/finalizers,verbs=update
//+kubebuilder:rbac:groups=admissionregistration.k8s.io,resources=mutatingwebhookconfigurations,verbs=get;list;watch;create;update;patch;delete

// MutationHandler validates Kubernetes resources using the KCL source.
type MutationHandler struct {
Expand Down

0 comments on commit 32aec04

Please sign in to comment.