Skip to content

Commit ef1526b

Browse files
committed
Add v2beta1 webhook
1 parent c481218 commit ef1526b

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

cmd/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
pdoknlv2beta1 "github.com/pdok/atom-operator/api/v2beta1"
4141
pdoknlv3 "github.com/pdok/atom-operator/api/v3"
4242
"github.com/pdok/atom-operator/internal/controller"
43+
webhookpdoknlv2beta1 "github.com/pdok/atom-operator/internal/webhook/v2beta1"
4344
webhookpdoknlv3 "github.com/pdok/atom-operator/internal/webhook/v3"
4445
// +kubebuilder:scaffold:imports
4546
)
@@ -212,6 +213,15 @@ func main() {
212213
setupLog.Error(err, "unable to create controller", "controller", "Atom")
213214
os.Exit(1)
214215
}
216+
217+
// nolint:goconst
218+
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
219+
if err = webhookpdoknlv2beta1.SetupAtomWebhookWithManager(mgr); err != nil {
220+
setupLog.Error(err, "unable to create webhook", "webhook", "Atom")
221+
os.Exit(1)
222+
}
223+
}
224+
215225
// nolint:goconst
216226
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
217227
if err = webhookpdoknlv3.SetupAtomWebhookWithManager(mgr); err != nil {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2024 Publieke Dienstverlening op de Kaart
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
package v3
26+
27+
import (
28+
ctrl "sigs.k8s.io/controller-runtime"
29+
logf "sigs.k8s.io/controller-runtime/pkg/log"
30+
31+
pdoknlv2beta1 "github.com/pdok/atom-operator/api/v2beta1"
32+
)
33+
34+
// nolint:unused
35+
// log is for logging in this package.
36+
var atomlog = logf.Log.WithName("atom-resource")
37+
38+
// SetupAtomWebhookWithManager registers the webhook for Atom in the manager.
39+
func SetupAtomWebhookWithManager(mgr ctrl.Manager) error {
40+
return ctrl.NewWebhookManagedBy(mgr).For(&pdoknlv2beta1.Atom{}).
41+
// Todo add WithValidator / AtomCustomValidator ?
42+
// Todo add WithDefaulter / AtomCustomDefaulter ?
43+
Complete()
44+
}
45+
46+
// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!

0 commit comments

Comments
 (0)