Skip to content

Commit 66d18d9

Browse files
authored
Merge pull request kubernetes-sigs#9460 from Ankitasw/move-docker-exp-api-webhooks
🌱 Move docker infrastructure experimental API v1beta1 webhooks to sepa…
2 parents 1ab45a6 + 0acadd5 commit 66d18d9

File tree

5 files changed

+76
-3
lines changed

5 files changed

+76
-3
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package webhooks implements docker infrastructure exp webhooks.
18+
package webhooks

test/infrastructure/docker/exp/api/v1beta1/dockermachinepool_webhook.go renamed to test/infrastructure/docker/exp/internal/webhooks/dockermachinepool_webhook.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package v1beta1
17+
package webhooks
1818

1919
import (
2020
ctrl "sigs.k8s.io/controller-runtime"
21+
22+
infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1"
2123
)
2224

25+
// DockerMachinePool implements a validating and defaulting webhook for DockerMachinePool.
26+
type DockerMachinePool struct{}
27+
2328
func (c *DockerMachinePool) SetupWebhookWithManager(mgr ctrl.Manager) error {
2429
return ctrl.NewWebhookManagedBy(mgr).
25-
For(c).
30+
For(&infraexpv1.DockerMachinePool{}).
2631
Complete()
2732
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package webhooks
18+
19+
import (
20+
ctrl "sigs.k8s.io/controller-runtime"
21+
22+
"sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/internal/webhooks"
23+
)
24+
25+
// DockerMachinePool implements a validating and defaulting webhook for DockerMachinePool.
26+
type DockerMachinePool struct{}
27+
28+
// SetupWebhookWithManager sets up DockerMachinePool webhooks.
29+
func (webhook *DockerMachinePool) SetupWebhookWithManager(mgr ctrl.Manager) error {
30+
return (&webhooks.DockerMachinePool{}).SetupWebhookWithManager(mgr)
31+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package webhooks contains docker infrastructure experimental webhook implementations for some of our API types.
18+
package webhooks

test/infrastructure/docker/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import (
5555
infraexpv1alpha4 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1alpha4"
5656
infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1"
5757
expcontrollers "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/controllers"
58+
"sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/webhooks"
5859
"sigs.k8s.io/cluster-api/util/flags"
5960
"sigs.k8s.io/cluster-api/version"
6061
)
@@ -377,7 +378,7 @@ func setupWebhooks(mgr ctrl.Manager) {
377378
}
378379

379380
if feature.Gates.Enabled(feature.MachinePool) {
380-
if err := (&infraexpv1.DockerMachinePool{}).SetupWebhookWithManager(mgr); err != nil {
381+
if err := (&webhooks.DockerMachinePool{}).SetupWebhookWithManager(mgr); err != nil {
381382
setupLog.Error(err, "unable to create webhook", "webhook", "DockerMachinePool")
382383
os.Exit(1)
383384
}

0 commit comments

Comments
 (0)