Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Move docker infrastructure experimental API v1beta1 webhooks to separate package #9460

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions test/infrastructure/docker/exp/internal/webhooks/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright 2023 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 implements docker infrastructure exp webhooks.
package webhooks
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1
package webhooks

import (
ctrl "sigs.k8s.io/controller-runtime"

infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1"
)

// DockerMachinePool implements a validating and defaulting webhook for DockerMachinePool.
type DockerMachinePool struct{}

func (c *DockerMachinePool) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(c).
For(&infraexpv1.DockerMachinePool{}).
Complete()
}
31 changes: 31 additions & 0 deletions test/infrastructure/docker/exp/webhooks/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2023 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 (
ctrl "sigs.k8s.io/controller-runtime"

"sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/internal/webhooks"
)

// DockerMachinePool implements a validating and defaulting webhook for DockerMachinePool.
type DockerMachinePool struct{}

// SetupWebhookWithManager sets up DockerMachinePool webhooks.
func (webhook *DockerMachinePool) SetupWebhookWithManager(mgr ctrl.Manager) error {
return (&webhooks.DockerMachinePool{}).SetupWebhookWithManager(mgr)
}
18 changes: 18 additions & 0 deletions test/infrastructure/docker/exp/webhooks/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright 2023 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 docker infrastructure experimental webhook implementations for some of our API types.
package webhooks
3 changes: 2 additions & 1 deletion test/infrastructure/docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
infraexpv1alpha4 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1alpha4"
infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1"
expcontrollers "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/controllers"
"sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/webhooks"
"sigs.k8s.io/cluster-api/util/flags"
"sigs.k8s.io/cluster-api/version"
)
Expand Down Expand Up @@ -377,7 +378,7 @@ func setupWebhooks(mgr ctrl.Manager) {
}

if feature.Gates.Enabled(feature.MachinePool) {
if err := (&infraexpv1.DockerMachinePool{}).SetupWebhookWithManager(mgr); err != nil {
if err := (&webhooks.DockerMachinePool{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "DockerMachinePool")
os.Exit(1)
}
Expand Down
Loading