Skip to content

Commit dc32a86

Browse files
committed
Upgrade to Operator SDK 1.41.1
This commit upgrades the designate-operator to use Operator SDK version 1.41.1, with the following major changes: Project Structure: - Move pkg/ packages to internal/ following Go best practices - Move controllers/ to internal/controller/ per new operator-sdk layout - Replace main.go with cmd/main.go - Add controller and webhook test suites Configuration Updates: - Split certificate management into separate metrics and webhook certs - Add network policies for metrics and webhook traffic - Rename auth_proxy resources to metrics for clarity - Add admin RBAC roles for all CRD types - Update manager deployment configuration and patches - Modernize kustomization configurations Webhook Changes: - Add dedicated webhook implementation in internal/webhook/v1beta1/ - Remove old CRD webhook and CA injection patches - Update webhook manifests and service configuration Cleanup: - Remove obsolete config patches and overlays Dependencies: - Update go.mod and go.sum for operator-sdk 1.41.1 dependencies Jira: OSPRH-21933 Assisted-by: claude-4-sonnet Signed-off-by: Martin Schuppert <[email protected]>
1 parent 547f59f commit dc32a86

File tree

165 files changed

+1674
-922
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+1674
-922
lines changed

.ci-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build_root_image:
22
name: tools
33
namespace: openstack-k8s-operators
4-
tag: ci-build-root-golang-1.24-sdk-1.31
4+
tag: ci-build-root-golang-1.24-sdk-1.41.1

.github/workflows/build-designate-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
operator_name: designate
1818
go_version: 1.24.x
19-
operator_sdk_version: 1.31.0
19+
operator_sdk_version: 1.41.1
2020
secrets:
2121
IMAGENAMESPACE: ${{ secrets.IMAGENAMESPACE }}
2222
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}

.github/workflows/force-bump-pr-manual.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ jobs:
99
with:
1010
operator_name: designate
1111
branch_name: ${{ github.ref_name }}
12-
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.31
12+
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.41.1
1313
secrets:
1414
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}

.github/workflows/force-bump-pr-scheduled.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
uses: openstack-k8s-operators/openstack-k8s-operators-ci/.github/workflows/force-bump-branches.yaml@main
1111
with:
1212
operator_name: designate
13-
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.31
13+
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.41.1
1414
secrets:
1515
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RUN mkdir -p ${DEST_ROOT}/usr/local/bin/
2424
RUN if [ ! -f $CACHITO_ENV_FILE ]; then go mod download ; fi
2525

2626
# Build manager
27-
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; env ${GO_BUILD_EXTRA_ENV_ARGS} go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager main.go
27+
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; env ${GO_BUILD_EXTRA_ENV_ARGS} go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager cmd/main.go
2828

2929
RUN cp -r templates ${DEST_ROOT}/templates
3030

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ golangci-lint:
124124

125125
.PHONY: test
126126
test: manifests generate fmt vet envtest ginkgo ## Run tests.
127-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" OPERATOR_TEMPLATES="$(shell pwd)/templates" $(GINKGO) -v --trace --cover --coverpkg=../../pkg/,../../controllers,../../api/v1beta1 --coverprofile cover.out --covermode=atomic --randomize-all ${PROC_CMD} $(GINKGO_ARGS) ./tests/...
127+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" OPERATOR_TEMPLATES="$(shell pwd)/templates" $(GINKGO) -v --trace --cover --coverpkg=../../internal/...,../../api/v1beta1/... --coverprofile cover.out --covermode=atomic --randomize-all ${PROC_CMD} $(GINKGO_ARGS) ./test/...
128128

129129
##@ Build
130130

131131
.PHONY: build
132132
build: generate fmt vet ## Build manager binary.
133-
go build -o bin/manager main.go
133+
go build -o bin/manager cmd/main.go
134134

135135
.PHONY: run
136136
run: export METRICS_PORT?=8080
@@ -140,7 +140,7 @@ run: export ENABLE_WEBHOOKS?=false
140140
run: export OPERATOR_TEMPLATES=./templates/
141141
run: manifests generate fmt vet ## Run a controller from your host.
142142
/bin/bash hack/clean_local_webhook.sh
143-
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
143+
go run ./cmd/main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
144144

145145
.PHONY: docker-build
146146
docker-build: test ## Build docker image with the manager.
@@ -188,9 +188,9 @@ OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
188188
GINKGO ?= $(LOCALBIN)/ginkgo
189189

190190
## Tool Versions
191-
KUSTOMIZE_VERSION ?= v3.8.7
191+
KUSTOMIZE_VERSION ?= v5.6.0
192192
CONTROLLER_TOOLS_VERSION ?= v0.18.0
193-
OPERATOR_SDK_VERSION ?= v1.31.0
193+
OPERATOR_SDK_VERSION ?= v1.41.1
194194
GOTOOLCHAIN_VERSION ?= go1.24.0
195195

196196
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"

PROJECT

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
# Code generated by tool. DO NOT EDIT.
2+
# This file is used to track the info used to scaffold your project
3+
# and allow the plugins properly work.
4+
# More info: https://book.kubebuilder.io/reference/project-config.html
15
domain: openstack.org
26
layout:
3-
- go.kubebuilder.io/v3
7+
- go.kubebuilder.io/v4
48
plugins:
59
manifests.sdk.operatorframework.io/v2: {}
610
scorecard.sdk.operatorframework.io/v2: {}

api/go.mod

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@ module github.com/openstack-k8s-operators/designate-operator/api
33
go 1.24.4
44

55
require (
6-
github.com/onsi/ginkgo/v2 v2.27.2
76
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251103072528-9eb684fef4ef
87
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251103072528-9eb684fef4ef
98
k8s.io/api v0.31.13
109
k8s.io/apimachinery v0.31.13
11-
k8s.io/client-go v0.31.13
10+
k8s.io/client-go v0.31.13 // indirect
1211
sigs.k8s.io/controller-runtime v0.19.7
1312
)
1413

15-
require (
16-
github.com/onsi/gomega v1.38.2
17-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251101153632-7b8179a60945
18-
)
14+
require github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251110170511-c2d4a351a7c3
1915

2016
require (
21-
github.com/Masterminds/semver/v3 v3.4.0 // indirect
2217
github.com/beorn7/perks v1.0.1 // indirect
2318
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2419
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
@@ -28,18 +23,15 @@ require (
2823
github.com/fsnotify/fsnotify v1.9.0 // indirect
2924
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
3025
github.com/go-logr/logr v1.4.3 // indirect
31-
github.com/go-logr/zapr v1.3.0 // indirect
3226
github.com/go-openapi/jsonpointer v0.21.1 // indirect
3327
github.com/go-openapi/jsonreference v0.21.0 // indirect
3428
github.com/go-openapi/swag v0.23.1 // indirect
35-
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
3629
github.com/gogo/protobuf v1.3.2 // indirect
3730
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3831
github.com/golang/protobuf v1.5.4 // indirect
3932
github.com/google/gnostic-models v0.7.0 // indirect
4033
github.com/google/go-cmp v0.7.0 // indirect
4134
github.com/google/gofuzz v1.2.0 // indirect
42-
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
4335
github.com/google/uuid v1.6.0 // indirect
4436
github.com/imdario/mergo v0.3.16 // indirect
4537
github.com/josharian/intern v1.0.0 // indirect
@@ -53,22 +45,18 @@ require (
5345
github.com/prometheus/client_model v0.6.2 // indirect
5446
github.com/prometheus/common v0.65.0 // indirect
5547
github.com/prometheus/procfs v0.16.1 // indirect
48+
github.com/rogpeppe/go-internal v1.13.1 // indirect
5649
github.com/spf13/pflag v1.0.7 // indirect
5750
github.com/x448/float16 v0.8.4 // indirect
58-
go.uber.org/multierr v1.11.0 // indirect
59-
go.uber.org/zap v1.27.0 // indirect
6051
go.yaml.in/yaml/v2 v2.4.2 // indirect
6152
go.yaml.in/yaml/v3 v3.0.4 // indirect
6253
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect
63-
golang.org/x/mod v0.27.0 // indirect
6454
golang.org/x/net v0.43.0 // indirect
6555
golang.org/x/oauth2 v0.30.0 // indirect
66-
golang.org/x/sync v0.17.0 // indirect
6756
golang.org/x/sys v0.36.0 // indirect
6857
golang.org/x/term v0.35.0 // indirect
6958
golang.org/x/text v0.29.0 // indirect
7059
golang.org/x/time v0.12.0 // indirect
71-
golang.org/x/tools v0.36.0 // indirect
7260
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
7361
google.golang.org/protobuf v1.36.7 // indirect
7462
gopkg.in/inf.v0 v0.9.1 // indirect

api/go.sum

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S
1818
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
1919
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
2020
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
21-
github.com/gkampitakis/ciinfo v0.3.2 h1:JcuOPk8ZU7nZQjdUhctuhQofk7BGHuIy0c9Ez8BNhXs=
22-
github.com/gkampitakis/ciinfo v0.3.2/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo=
23-
github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZdC4M=
24-
github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk=
25-
github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01KS3zGE=
26-
github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc=
2721
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
2822
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
2923
github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
@@ -36,8 +30,6 @@ github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZ
3630
github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0=
3731
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
3832
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
39-
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
40-
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
4133
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
4234
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
4335
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
@@ -60,8 +52,6 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
6052
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
6153
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
6254
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
63-
github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE=
64-
github.com/joshdk/go-junit v1.0.0/go.mod h1:TiiV0PqkaNfFXjEiyjWM3XXrhVyCa1K4Zfga6W52ung=
6555
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
6656
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
6757
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
@@ -76,10 +66,6 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
7666
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
7767
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
7868
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
79-
github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo=
80-
github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg=
81-
github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE=
82-
github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A=
8369
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
8470
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
8571
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -92,8 +78,8 @@ github.com/onsi/ginkgo/v2 v2.27.2 h1:LzwLj0b89qtIy6SSASkzlNvX6WktqurSHwkk2ipF/Ns
9278
github.com/onsi/ginkgo/v2 v2.27.2/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
9379
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
9480
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
95-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251101153632-7b8179a60945 h1:KIhwTggQV+vJtezk/FAeHH2nurq+v5b1tSdKI1OqyC4=
96-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251101153632-7b8179a60945/go.mod h1:u2rklI+ckD8yjjFgClqAWMwJXp0Rq7nkmTDinO8T6yg=
81+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251110170511-c2d4a351a7c3 h1:gKazSLpq0Ytn4OLzNtSKQpLswAdki8u8mXZgpJy83bE=
82+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251110170511-c2d4a351a7c3/go.mod h1:Y9LqOS1wYhn7RT4jFknINdWa+ziYEIOU1jLNxkxiCsw=
9783
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251103072528-9eb684fef4ef h1:1j7kk+D4ZdIXm6C/IwEjuTzIuvWUytxO39E/x94JY7k=
9884
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251103072528-9eb684fef4ef/go.mod h1:kUT/SyuxZiOcX8ZuvpFN3PaQa2V8uQon8YwY+1RoQWM=
9985
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251103072528-9eb684fef4ef h1:VMwP0988m1VCjpVn+MxHt7i3B0OuBhQnM5akKt4taVA=
@@ -119,14 +105,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
119105
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
120106
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
121107
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
122-
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
123-
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
124-
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
125-
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
126-
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
127-
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
128-
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
129-
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
130108
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
131109
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
132110
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

api/v1beta1/designate_webhook.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"k8s.io/apimachinery/pkg/runtime"
3131
"k8s.io/apimachinery/pkg/runtime/schema"
3232
"k8s.io/apimachinery/pkg/util/validation/field"
33-
ctrl "sigs.k8s.io/controller-runtime"
3433
logf "sigs.k8s.io/controller-runtime/pkg/log"
3534
"sigs.k8s.io/controller-runtime/pkg/webhook"
3635
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
@@ -60,15 +59,6 @@ func SetupDesignateDefaults(defaults DesignateDefaults) {
6059
designatelog.Info("Designate defaults initialized", "defaults", defaults)
6160
}
6261

63-
// SetupWebhookWithManager sets up the webhook with the Manager
64-
func (r *Designate) SetupWebhookWithManager(mgr ctrl.Manager) error {
65-
return ctrl.NewWebhookManagedBy(mgr).
66-
For(r).
67-
Complete()
68-
}
69-
70-
//+kubebuilder:webhook:path=/mutate-designate-openstack-org-v1beta1-designate,mutating=true,failurePolicy=fail,sideEffects=None,groups=designate.openstack.org,resources=designates,verbs=create;update,versions=v1beta1,name=mdesignate.kb.io,admissionReviewVersions=v1
71-
7262
var _ webhook.Defaulter = &Designate{}
7363

7464
// Default implements webhook.Defaulter so a webhook will be registered for the type
@@ -108,13 +98,11 @@ func (spec *DesignateSpec) Default() {
10898
}
10999
}
110100

101+
// Default implements defaulting for DesignateSpecCore
111102
func (spec *DesignateSpecCore) Default() {
112103
// validations go here for the ControlPlane
113104
}
114105

115-
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
116-
//+kubebuilder:webhook:path=/validate-designate-openstack-org-v1beta1-designate,mutating=false,failurePolicy=fail,sideEffects=None,groups=designate.openstack.org,resources=designates,verbs=create;update,versions=v1beta1,name=vdesignate.kb.io,admissionReviewVersions=v1
117-
118106
var _ webhook.Validator = &Designate{}
119107

120108
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
@@ -152,6 +140,8 @@ func (r *DesignateSpec) ValidateCreate(basePath *field.Path, namespace string) f
152140
return allErrs
153141
}
154142

143+
// ValidateCreate - Exported function wrapping non-exported validate functions,
144+
// this function can be called externally to validate a designate spec core.
155145
func (r *DesignateSpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
156146
var allErrs field.ErrorList
157147

@@ -204,6 +194,8 @@ func (r *DesignateSpec) ValidateUpdate(old DesignateSpec, basePath *field.Path,
204194
return allErrs
205195
}
206196

197+
// ValidateUpdate - Exported function wrapping non-exported validate functions,
198+
// this function can be called externally to validate a designate spec core.
207199
func (r *DesignateSpecCore) ValidateUpdate(old DesignateSpecCore, basePath *field.Path, namespace string) field.ErrorList {
208200
var allErrs field.ErrorList
209201

@@ -224,6 +216,7 @@ func (r *Designate) ValidateDelete() (admission.Warnings, error) {
224216
return nil, nil
225217
}
226218

219+
// GetDefaultRouteAnnotations - Returns the default route annotations for the DesignateSpecCore
227220
func (spec *DesignateSpecCore) GetDefaultRouteAnnotations() (annotations map[string]string) {
228221
return map[string]string{
229222
"haproxy.router.openshift.io/timeout": fmt.Sprintf("%ds", designateDefaults.DesignateAPIRouteTimeout),

0 commit comments

Comments
 (0)