Skip to content

Commit

Permalink
Merge pull request #9460 from Ankitasw/move-docker-exp-api-webhooks
Browse files Browse the repository at this point in the history
🌱 Move docker  infrastructure experimental API v1beta1 webhooks to sepa…
  • Loading branch information
k8s-ci-robot committed Sep 19, 2023
2 parents 1ab45a6 + 0acadd5 commit 66d18d9
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 3 deletions.
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

0 comments on commit 66d18d9

Please sign in to comment.