Skip to content

Commit

Permalink
Merge pull request #5711 from kaitoii11/webhook-internalize
Browse files Browse the repository at this point in the history
🌱 Move webhooks to internal
  • Loading branch information
k8s-ci-robot authored Nov 22, 2021
2 parents 10048c6 + d096694 commit f5e79e2
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ generate-manifests-core: $(CONTROLLER_GEN) $(KUSTOMIZE)
$(CONTROLLER_GEN) \
paths=./api/... \
paths=./controllers/... \
paths=./webhooks/... \
paths=./internal/webhooks/... \
paths=./$(EXP_DIR)/api/... \
paths=./$(EXP_DIR)/controllers/... \
paths=./$(EXP_DIR)/addons/api/... \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions internal/webhooks/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package webhooks contains external webhook implementations for some of our API types.
package webhooks
File renamed without changes.
43 changes: 43 additions & 0 deletions webhooks/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package webhooks

import (
"sigs.k8s.io/cluster-api/internal/webhooks"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// Cluster implements a validating and defaulting webhook for Cluster.
type Cluster struct {
Client client.Reader
}

// SetupWebhookWithManager sets up Cluster webhooks.
func (webhook *Cluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
return (&webhooks.Cluster{
Client: webhook.Client,
}).SetupWebhookWithManager(mgr)
}

// ClusterClass implements a validation and defaulting webhook for ClusterClass.
type ClusterClass struct{}

// SetupWebhookWithManager sets up ClusterClass webhooks.
func (webhook *ClusterClass) SetupWebhookWithManager(mgr ctrl.Manager) error {
return (&webhooks.ClusterClass{}).SetupWebhookWithManager(mgr)
}

0 comments on commit f5e79e2

Please sign in to comment.