Skip to content

Commit d352443

Browse files
committed
Upgrade to operator-sdk 1.41.1
Rescaffold the barbican-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 - Add missing APIs to PROJECT - 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-21925 Depends-On: openstack-k8s-operators/openstack-operator#1683
1 parent d5429ec commit d352443

File tree

128 files changed

+1392
-931
lines changed

Some content is hidden

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

128 files changed

+1392
-931
lines changed

.github/workflows/build-barbican-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: barbican
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 }}

Dockerfile

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

2828
# Build manager
29-
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
29+
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
3030

3131
RUN cp -r templates ${DEST_ROOT}/templates
3232

Makefile

Lines changed: 5 additions & 5 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/barbican-operator:latest
@@ -125,13 +125,13 @@ PROC_CMD = --procs ${PROCS}
125125
test: manifests generate fmt vet envtest ginkgo ## Run tests.
126126
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
127127
OPERATOR_TEMPLATES="$(shell pwd)/templates" \
128-
$(GINKGO) --trace --cover --coverpkg=../../pkg/barbican,../../controllers,../../api/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./tests/...
128+
$(GINKGO) --trace --cover --coverpkg=../../internal/barbican,../../internal/controller,../../api/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./test/...
129129

130130
##@ Build
131131

132132
.PHONY: build
133133
build: manifests generate fmt vet ## Build manager binary.
134-
go build -o bin/manager main.go
134+
go build -o bin/manager cmd/main.go
135135

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

146146
# If you wish built the manager image targeting other platforms you can use the --platform flag.
147147
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
@@ -208,7 +208,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
208208
GINKGO ?= $(LOCALBIN)/ginkgo
209209

210210
## Tool Versions
211-
KUSTOMIZE_VERSION ?= v3.8.7
211+
KUSTOMIZE_VERSION ?= v5.6.0
212212
CONTROLLER_TOOLS_VERSION ?= v0.18.0
213213
GOTOOLCHAIN_VERSION ?= go1.24.0
214214

PROJECT

Lines changed: 14 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: {}
@@ -38,4 +42,13 @@ resources:
3842
kind: BarbicanWorker
3943
path: github.com/openstack-k8s-operators/barbican-operator/api/v1beta1
4044
version: v1beta1
45+
- api:
46+
crdVersion: v1
47+
namespaced: true
48+
controller: true
49+
domain: openstack.org
50+
group: barbican
51+
kind: BarbicanKeystoneListener
52+
path: github.com/openstack-k8s-operators/barbican-operator/api/v1beta1
53+
version: v1beta1
4154
version: "3"

api/bases/barbican.openstack.org_barbicanapis.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ spec:
9898
type: boolean
9999
enabledSecretStores:
100100
items:
101-
description: This SecretStore type is used by the EnabledSecretStores
101+
description: SecretStore type is used by the EnabledSecretStores
102102
variable inside the specification.
103103
enum:
104104
- simple_crypto
@@ -110,8 +110,8 @@ spec:
110110
x-kubernetes-list-type: set
111111
globalDefaultSecretStore:
112112
default: simple_crypto
113-
description: This SecretStore type is used by the EnabledSecretStores
114-
variable inside the specification.
113+
description: SecretStore type is used by the EnabledSecretStores variable
114+
inside the specification.
115115
enum:
116116
- simple_crypto
117117
- pkcs11

api/bases/barbican.openstack.org_barbicankeystonelisteners.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ spec:
9090
type: object
9191
enabledSecretStores:
9292
items:
93-
description: This SecretStore type is used by the EnabledSecretStores
93+
description: SecretStore type is used by the EnabledSecretStores
9494
variable inside the specification.
9595
enum:
9696
- simple_crypto
@@ -102,8 +102,8 @@ spec:
102102
x-kubernetes-list-type: set
103103
globalDefaultSecretStore:
104104
default: simple_crypto
105-
description: This SecretStore type is used by the EnabledSecretStores
106-
variable inside the specification.
105+
description: SecretStore type is used by the EnabledSecretStores variable
106+
inside the specification.
107107
enum:
108108
- simple_crypto
109109
- pkcs11

api/bases/barbican.openstack.org_barbicans.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ spec:
670670
type: object
671671
enabledSecretStores:
672672
items:
673-
description: This SecretStore type is used by the EnabledSecretStores
673+
description: SecretStore type is used by the EnabledSecretStores
674674
variable inside the specification.
675675
enum:
676676
- simple_crypto
@@ -682,8 +682,8 @@ spec:
682682
x-kubernetes-list-type: set
683683
globalDefaultSecretStore:
684684
default: simple_crypto
685-
description: This SecretStore type is used by the EnabledSecretStores
686-
variable inside the specification.
685+
description: SecretStore type is used by the EnabledSecretStores variable
686+
inside the specification.
687687
enum:
688688
- simple_crypto
689689
- pkcs11

api/bases/barbican.openstack.org_barbicanworkers.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ spec:
8888
type: object
8989
enabledSecretStores:
9090
items:
91-
description: This SecretStore type is used by the EnabledSecretStores
91+
description: SecretStore type is used by the EnabledSecretStores
9292
variable inside the specification.
9393
enum:
9494
- simple_crypto
@@ -100,8 +100,8 @@ spec:
100100
x-kubernetes-list-type: set
101101
globalDefaultSecretStore:
102102
default: simple_crypto
103-
description: This SecretStore type is used by the EnabledSecretStores
104-
variable inside the specification.
103+
description: SecretStore type is used by the EnabledSecretStores variable
104+
inside the specification.
105105
enum:
106106
- simple_crypto
107107
- pkcs11

api/v1beta1/barbican_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const (
4242
// BarbicanKeystoneListenerContainerImage is the fall-back container image for BarbicanAPI
4343
BarbicanKeystoneListenerContainerImage = "quay.io/podified-antelope-centos9/openstack-barbican-keystone-listener:current-podified"
4444

45-
// Barbican API timeout
45+
// APITimeout is the default Barbican API timeout
4646
APITimeout = 90
4747
)
4848

api/v1beta1/barbican_webhook.go

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -131,41 +131,43 @@ func (r *Barbican) ValidateCreate() (admission.Warnings, error) {
131131

132132
// ValidateCreate - Exported function wrapping non-exported validate functions,
133133
// this function can be called externally to validate an barbican spec.
134-
func (r *BarbicanSpec) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
134+
func (spec *BarbicanSpec) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
135135
var allErrs field.ErrorList
136136

137137
// validate the service override key is valid
138138
allErrs = append(allErrs, service.ValidateRoutedOverrides(
139139
basePath.Child("barbicanAPI").Child("override").Child("service"),
140-
r.BarbicanAPI.Override.Service)...)
140+
spec.BarbicanAPI.Override.Service)...)
141141

142142
// pkcs11 verifications
143-
r.ValidatePKCS11(basePath, &allErrs)
143+
spec.ValidatePKCS11(basePath, &allErrs)
144144

145-
allErrs = append(allErrs, r.ValidateBarbicanTopology(basePath, namespace)...)
145+
allErrs = append(allErrs, spec.ValidateBarbicanTopology(basePath, namespace)...)
146146

147147
return allErrs
148148
}
149149

150-
func (r *BarbicanSpec) ValidatePKCS11(basePath *field.Path, allErrs *field.ErrorList) {
151-
if slices.Contains(r.EnabledSecretStores, SecretStorePKCS11) {
152-
if r.PKCS11 == nil {
150+
// ValidatePKCS11 validates that PKCS11 configuration is provided when PKCS11 is an enabled secret store
151+
func (spec *BarbicanSpec) ValidatePKCS11(basePath *field.Path, allErrs *field.ErrorList) {
152+
if slices.Contains(spec.EnabledSecretStores, SecretStorePKCS11) {
153+
if spec.PKCS11 == nil {
153154
*allErrs = append(*allErrs, field.Required(basePath.Child("PKCS11"),
154155
"PKCS11 specification is missing, PKCS11 is required when pkcs11 is an enabled SecretStore"),
155156
)
156157
}
157158
}
158159
}
159160

160-
func (r *BarbicanSpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
161+
// ValidateCreate validates BarbicanSpecCore on creation
162+
func (spec *BarbicanSpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
161163
var allErrs field.ErrorList
162164

163165
// validate the service override key is valid
164166
allErrs = append(allErrs, service.ValidateRoutedOverrides(
165167
basePath.Child("barbicanAPI").Child("override").Child("service"),
166-
r.BarbicanAPI.Override.Service)...)
168+
spec.BarbicanAPI.Override.Service)...)
167169

168-
allErrs = append(allErrs, r.ValidateBarbicanTopology(basePath, namespace)...)
170+
allErrs = append(allErrs, spec.ValidateBarbicanTopology(basePath, namespace)...)
169171
return allErrs
170172
}
171173

@@ -196,30 +198,31 @@ func (r *Barbican) ValidateUpdate(old runtime.Object) (admission.Warnings, error
196198

197199
// ValidateUpdate - Exported function wrapping non-exported validate functions,
198200
// this function can be called externally to validate an barbican spec.
199-
func (r *BarbicanSpec) ValidateUpdate(old BarbicanSpec, basePath *field.Path, namespace string) field.ErrorList {
201+
func (spec *BarbicanSpec) ValidateUpdate(old BarbicanSpec, basePath *field.Path, namespace string) field.ErrorList {
200202
var allErrs field.ErrorList
201203

202204
// validate the service override key is valid
203205
allErrs = append(allErrs, service.ValidateRoutedOverrides(
204206
basePath.Child("barbicanAPI").Child("override").Child("service"),
205-
r.BarbicanAPI.Override.Service)...)
207+
spec.BarbicanAPI.Override.Service)...)
206208

207209
// pkcs11 verifications
208-
r.ValidatePKCS11(basePath, &allErrs)
210+
spec.ValidatePKCS11(basePath, &allErrs)
209211

210-
allErrs = append(allErrs, r.ValidateBarbicanTopology(basePath, namespace)...)
212+
allErrs = append(allErrs, spec.ValidateBarbicanTopology(basePath, namespace)...)
211213
return allErrs
212214
}
213215

214-
func (r *BarbicanSpecCore) ValidateUpdate(old BarbicanSpecCore, basePath *field.Path, namespace string) field.ErrorList {
216+
// ValidateUpdate validates BarbicanSpecCore on update
217+
func (spec *BarbicanSpecCore) ValidateUpdate(old BarbicanSpecCore, basePath *field.Path, namespace string) field.ErrorList {
215218
var allErrs field.ErrorList
216219

217220
// validate the service override key is valid
218221
allErrs = append(allErrs, service.ValidateRoutedOverrides(
219222
basePath.Child("barbicanAPI").Child("override").Child("service"),
220-
r.BarbicanAPI.Override.Service)...)
223+
spec.BarbicanAPI.Override.Service)...)
221224

222-
allErrs = append(allErrs, r.ValidateBarbicanTopology(basePath, namespace)...)
225+
allErrs = append(allErrs, spec.ValidateBarbicanTopology(basePath, namespace)...)
223226
return allErrs
224227
}
225228

@@ -231,6 +234,7 @@ func (r *Barbican) ValidateDelete() (admission.Warnings, error) {
231234
return nil, nil
232235
}
233236

237+
// GetDefaultRouteAnnotations returns the default route annotations for Barbican API
234238
func (spec *BarbicanSpecCore) GetDefaultRouteAnnotations() (annotations map[string]string) {
235239
return map[string]string{
236240
"haproxy.router.openshift.io/timeout": fmt.Sprintf("%ds", barbicanDefaults.BarbicanAPITimeout),

0 commit comments

Comments
 (0)