Skip to content

Commit d0c6e56

Browse files
committed
Upgrade to operator-sdk 1.41.1
Rescaffold the watcher-operator to operator-sdk 1.41.1, which includes: - Reorganize project structure (pkg/ -> internal/) - Move webhook implementations to internal/webhook/v1beta1/ - Add new cmd/main.go entrypoint with updated controller initialization - Update RBAC, certmanager, and prometheus configurations - Enhance network policies for metrics and webhook traffic - Set watcher as defaulting resource in PROJECT file - Remove auto-generated test suite scaffolding - Update build workflow and Dockerfile to version 1.41.1 This upgrade modernizes the operator structure and aligns with the latest operator-sdk best practices. Jira: OSPRH-22014 Depends-On: openstack-k8s-operators/openstack-operator#1683
1 parent dadb736 commit d0c6e56

File tree

181 files changed

+1615
-789
lines changed

Some content is hidden

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

181 files changed

+1615
-789
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/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: watcher
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: watcher
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 }}

.zuul.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
A zuul job building content from OpenDev epoxy release.
139139
parent: openstack-meta-content-provider
140140
vars:
141+
cifmw_install_yamls_sdk_version: v1.41.1
141142
cifmw_bop_openstack_release: epoxy
142143
cifmw_bop_dlrn_baseurl: "https://trunk.rdoproject.org/centos9-epoxy"
143144
cifmw_repo_setup_branch: epoxy
@@ -208,6 +209,7 @@
208209
nodeset: centos-stream-10-vexxhost
209210
parent: openstack-meta-content-provider
210211
vars:
212+
cifmw_install_yamls_sdk_version: v1.41.1
211213
cifmw_bop_openstack_release: master
212214
cifmw_bop_dlrn_baseurl: "https://trunk.rdoproject.org/centos10-master"
213215
cifmw_repo_setup_branch: master

Dockerfile

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

2525
# Build manager
26-
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
26+
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
2727

2828

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

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ endif
4848

4949
# Set the Operator SDK version to use. By default, what is installed on the system is used.
5050
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
51-
OPERATOR_SDK_VERSION ?= v1.31.0
51+
OPERATOR_SDK_VERSION ?= v1.41.1
5252

5353
# Image URL to use all building/pushing image targets
5454
DEFAULT_IMG ?= quay.io/openstack-k8s-operators/watcher-operator:latest
@@ -146,22 +146,22 @@ PROC_CMD = --procs ${PROCS}
146146
.PHONY: test
147147
test: manifests generate fmt vet envtest ginkgo ## Run tests.
148148
OPERATOR_TEMPLATES="$(PWD)/templates" \
149-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) --trace --cover --coverpkg=../../pkg/watcher,../../controllers,../../api/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./tests/...
149+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) --trace --cover --coverpkg=../../internal/watcher,../../internal/controller,../../api/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./test/...
150150

151151

152152
##@ Build
153153

154154
.PHONY: build
155155
build: generate fmt vet ## Build manager binary.
156-
go build -o bin/manager main.go
156+
go build -o bin/manager cmd/main.go
157157

158158
.PHONY: run
159159
run: export METRICS_PORT?=24604
160160
run: export HEALTH_PORT?=24605
161161
run: export PPROF_PORT?=8082
162162
run: export ENABLE_WEBHOOKS?=false
163163
run: manifests generate fmt vet ## Run a controller from your host.
164-
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
164+
go run ./cmd/main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
165165

166166

167167
# Extra vars which will be passed to the Docker-build
@@ -212,7 +212,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
212212
GINKGO ?= $(LOCALBIN)/ginkgo
213213

214214
## Tool Versions
215-
KUSTOMIZE_VERSION ?= v3.8.7
215+
KUSTOMIZE_VERSION ?= v5.6.0
216216
CONTROLLER_TOOLS_VERSION ?= v0.18.0
217217
SETUP_ENVTEST_VERSION ?= release-0.22
218218

@@ -424,7 +424,7 @@ watcher_cleanup: ## Cleaning watcher operator via olm
424424

425425
KUTTL_SUITE ?= default
426426
KUTTL_NAMESPACE ?= watcher-kuttl-$(KUTTL_SUITE)
427-
KUTTL_SUITE_DIR ?= tests/kuttl/test-suites/$(KUTTL_SUITE)
427+
KUTTL_SUITE_DIR ?= test/kuttl/test-suites/$(KUTTL_SUITE)
428428

429429
.PHONY: stop_watcher_integrated
430430
stop_watcher_integrated:

PROJECT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# More info: https://book.kubebuilder.io/reference/project-config.html
55
domain: openstack.org
66
layout:
7-
- go.kubebuilder.io/v3
7+
- go.kubebuilder.io/v4
88
plugins:
99
manifests.sdk.operatorframework.io/v2: {}
1010
scorecard.sdk.operatorframework.io/v2: {}

api/v1beta1/common_types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ type PasswordSelector struct {
147147
Service *string `json:"service"`
148148
}
149149

150-
// WatcherSubCrsCommon
150+
// WatcherSubCrsCommon defines the common fields for Watcher sub-CRs
151151
type WatcherSubCrsCommon struct {
152152
// +kubebuilder:validation:Optional
153153
// The service specific Container Image URL (will be set to environmental default if empty)
@@ -189,6 +189,7 @@ type WatcherSubCrsTemplate struct {
189189
TopologyRef *topologyv1.TopoRef `json:"topologyRef,omitempty"`
190190
}
191191

192+
// WatcherImages defines the container images for all Watcher services
192193
type WatcherImages struct {
193194
// +kubebuilder:validation:Required
194195
// APIContainerImageURL
@@ -203,6 +204,7 @@ type WatcherImages struct {
203204
ApplierContainerImageURL string `json:"applierContainerImageURL"`
204205
}
205206

207+
// Default sets default values for WatcherImages based on the provided defaults
206208
func (r *WatcherImages) Default(defaults WatcherDefaults) {
207209
if r.APIContainerImageURL == "" {
208210
r.APIContainerImageURL = defaults.APIContainerImageURL
@@ -215,8 +217,7 @@ func (r *WatcherImages) Default(defaults WatcherDefaults) {
215217
}
216218
}
217219

218-
// SetupDefaults - initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks)
219-
220+
// SetupDefaults initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks)
220221
func SetupDefaults() {
221222
// Acquire environmental defaults and initialize Watcher defaults with them
222223
watcherDefaults := WatcherDefaults{

api/v1beta1/common_webhook.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

api/v1beta1/conditions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
55
const (
66
// WatcherRabbitMQTransportURLReadyCondition -
77
WatcherRabbitMQTransportURLReadyCondition condition.Type = "WatcherRabbitMQTransportURLReady"
8-
// WatcherNotificationsBusTransportURLReadyCondition -
8+
// WatcherNotificationTransportURLReadyCondition indicates whether the Watcher notification transport URL is ready
99
WatcherNotificationTransportURLReadyCondition condition.Type = "WatcherNotificationTransportURLReady"
1010
// WatcherAPIReadyCondition -
1111
WatcherAPIReadyCondition condition.Type = "WatcherAPIReady"

0 commit comments

Comments
 (0)