@@ -20,6 +20,12 @@ GO_VERSION = 1.20
20
20
ENVTEST_K8S_VERSION = 1.28
21
21
# See https://github.com/slintes/sort-imports/releases for the last version
22
22
SORT_IMPORTS_VERSION = v0.2.1
23
+ # OCP Version: for OKD bundle community
24
+ OCP_VERSION ?= 4.12
25
+ # update for major version updates to YQ_VERSION! see https://github.com/mikefarah/yq
26
+ # NOTE: v4.42.1 is the latest supporting go 1.20
27
+ YQ_API_VERSION = v4
28
+ YQ_VERSION = v4.42.1
23
29
24
30
# IMAGE_REGISTRY used to indicate the registery/group for the operator, bundle and catalog
25
31
IMAGE_REGISTRY ?= quay.io/medik8s
@@ -209,32 +215,64 @@ bundle-cleanup: operator-sdk ## Remove bundle installed via bundle-run
209
215
# # Some addition to bundle creation in the bundle
210
216
DEFAULT_ICON_BASE64 := $(shell base64 --wrap=0 ./config/assets/nmo_blue_icon.png)
211
217
export ICON_BASE64 ?= ${DEFAULT_ICON_BASE64}
212
- export BUNDLE_CSV ?= "./bundle/manifests/$(OPERATOR_NAME ) .clusterserviceversion.yaml"
218
+ export CSV ?= "./bundle/manifests/$(OPERATOR_NAME ) .clusterserviceversion.yaml"
213
219
214
220
.PHONY : bundle-update
215
- bundle-update : verify-previous-version # # Update CSV fields and validate the bundle directory
216
- sed -r -i " s|containerImage: .*|containerImage: $( IMG) |;" ${BUNDLE_CSV}
217
- sed -r -i " s|createdAt: .*|createdAt: ` date ' +%Y-%m-%d %T' ` |;" ${BUNDLE_CSV}
218
- sed -r -i " s|replaces: .*|replaces: $( OPERATOR_NAME) .v${PREVIOUS_VERSION} |;" ${BUNDLE_CSV}
219
- sed -r -i " s|base64data:.*|base64data: ${ICON_BASE64} |;" ${BUNDLE_CSV}
221
+ bundle-update : # # Update CSV fields and validate the bundle directory
222
+ sed -r -i " s|containerImage: .*|containerImage: $( IMG) |;" ${CSV}
223
+ sed -r -i " s|createdAt: .*|createdAt: ` date ' +%Y-%m-%d %T' ` |;" ${CSV}
224
+ sed -r -i " s|base64data:.*|base64data: ${ICON_BASE64} |;" ${CSV}
220
225
$(MAKE ) bundle-validate
221
226
222
- .PHONY : verify-previous-version
223
- verify-previous-version : # # Verifies that PREVIOUS_VERSION variable is set
224
- @if [ $( VERSION) != $( DEFAULT_VERSION) ] && [ $( VERSION) != $( CI_VERSION) ] && [ $( PREVIOUS_VERSION) = $( DEFAULT_VERSION) ]; then \
225
- echo " Error: PREVIOUS_VERSION must be set for the selected VERSION" ; \
226
- exit 1; \
227
+ .PHONY : add-replaces-field
228
+ add-replaces-field : # # Add replaces field to the CSV
229
+ # add replaces field when building versioned bundle
230
+ @if [ $( VERSION) != $( DEFAULT_VERSION) ]; then \
231
+ if [ $( PREVIOUS_VERSION) == $( DEFAULT_VERSION) ]; then \
232
+ echo " Error: PREVIOUS_VERSION must be set for versioned builds" ; \
233
+ exit 1; \
234
+ elif [ $( shell ./hack/semver_cmp.sh $( VERSION) $( PREVIOUS_VERSION) ) != 1 ]; then \
235
+ echo " Error: VERSION ($( VERSION) ) must be greater than PREVIOUS_VERSION ($( PREVIOUS_VERSION) )" ; \
236
+ exit 1; \
237
+ else \
238
+ # preferring sed here, in order to have "replaces" near "version" \
239
+ sed -r -i " / version: $( VERSION) / a\ replaces: $( OPERATOR_NAME) .v$( PREVIOUS_VERSION) " ${CSV} ; \
240
+ fi \
227
241
fi
228
242
229
243
.PHONY : bundle-reset-date
230
244
bundle-reset-date : # # Reset bundle's createdAt
231
- sed -r -i " s|createdAt: .*|createdAt: \"\" |;" ${BUNDLE_CSV }
245
+ sed -r -i " s|createdAt: .*|createdAt: \"\" |;" ${CSV }
232
246
233
247
.PHONY : bundle-community
234
- bundle-community : bundle-k8s # # Update displayName, and description fields in the bundle's CSV
235
- sed -r -i " s|displayName: Node Maintenance Operator|displayName: Node Maintenance Operator - Community Edition |;" ${BUNDLE_CSV }
248
+ bundle-community : # # Update displayName, and description fields in the bundle's CSV
249
+ sed -r -i " s|displayName: Node Maintenance Operator|displayName: Node Maintenance Operator - Community Edition |;" ${CSV }
236
250
$(MAKE ) bundle-update
237
251
252
+
253
+ .PHONY : bundle-community-k8s
254
+ bundle-community-k8s : bundle-k8s bundle-community # # Generate bundle manifests and metadata customized to Red Hat community release
255
+
256
+ .PHONY : bundle-community-okd
257
+ bundle-community-okd : bundle bundle-community # # Generate bundle manifests and metadata customized to Red Hat community release
258
+ $(MAKE ) add-replaces-field
259
+ $(MAKE ) add-ocp-annotations
260
+ echo -e " \n # Annotations for OCP\n com.redhat.openshift.versions: \" v${OCP_VERSION} \" " >> bundle/metadata/annotations.yaml
261
+
262
+
263
+ .PHONY : add-ocp-annotations
264
+ add-ocp-annotations : yq # # Add OCP annotations
265
+ $(YQ ) -i ' .metadata.annotations."operators.openshift.io/valid-subscription" = "[\"OpenShift Kubernetes Engine\", \"OpenShift Container Platform\", \"OpenShift Platform Plus\"]"' ${CSV}
266
+ # new infrastructure annotations see https://docs.engineering.redhat.com/display/CFC/Best_Practices#Best_Practices-(New)RequiredInfrastructureAnnotations
267
+ $(YQ ) -i ' .metadata.annotations."features.operators.openshift.io/disconnected" = "true"' ${CSV}
268
+ $(YQ ) -i ' .metadata.annotations."features.operators.openshift.io/fips-compliant" = "false"' ${CSV}
269
+ $(YQ ) -i ' .metadata.annotations."features.operators.openshift.io/proxy-aware" = "false"' ${CSV}
270
+ $(YQ ) -i ' .metadata.annotations."features.operators.openshift.io/tls-profiles" = "false"' ${CSV}
271
+ $(YQ ) -i ' .metadata.annotations."features.operators.openshift.io/token-auth-aws" = "false"' ${CSV}
272
+ $(YQ ) -i ' .metadata.annotations."features.operators.openshift.io/token-auth-azure" = "false"' ${CSV}
273
+ $(YQ ) -i ' .metadata.annotations."features.operators.openshift.io/token-auth-gcp" = "false"' ${CSV}
274
+
275
+
238
276
# #@ Build
239
277
240
278
.PHONY : build
@@ -291,6 +329,7 @@ GINKGO_DIR ?= $(LOCALBIN)/ginkgo
291
329
OPM_DIR = $(LOCALBIN ) /opm
292
330
OPERATOR_SDK_DIR ?= $(LOCALBIN ) /operator-sdk
293
331
SORT_IMPORTS_DIR ?= $(LOCALBIN ) /sort-imports
332
+ YQ_DIR ?= $(LOCALBIN ) /yq
294
333
295
334
# # Specific Tool Binaries
296
335
KUSTOMIZE = $(KUSTOMIZE_DIR ) /$(KUSTOMIZE_VERSION ) /kustomize
@@ -301,6 +340,7 @@ GINKGO = $(GINKGO_DIR)/$(GINKGO_VERSION)/ginkgo
301
340
OPM = $(OPM_DIR ) /$(OPM_VERSION ) /opm
302
341
OPERATOR_SDK = $(OPERATOR_SDK_DIR ) /$(OPERATOR_SDK_VERSION ) /operator-sdk
303
342
SORT_IMPORTS = $(SORT_IMPORTS_DIR ) /$(SORT_IMPORTS_VERSION ) /sort-imports
343
+ YQ = $(YQ_DIR ) /$(YQ_API_VERSION ) -$(YQ_VERSION ) /yq
304
344
305
345
.PHONY : kustomize
306
346
kustomize : # # Download kustomize locally if necessary.
@@ -326,6 +366,10 @@ ginkgo: ## Download ginkgo locally if necessary.
326
366
sort-imports : # # Download sort-imports locally if necessary.
327
367
$(call go-install-tool,$(SORT_IMPORTS ) ,$(SORT_IMPORTS_DIR ) ,github.com/slintes/sort-imports@$(SORT_IMPORTS_VERSION ) )
328
368
369
+ .PHONY : yq
370
+ yq : # # Download yq locally if necessary.
371
+ $(call go-install-tool,$(YQ ) ,$(YQ_DIR ) , github.com/mikefarah/yq/$(YQ_API_VERSION ) @$(YQ_VERSION ) )
372
+
329
373
# go-install-tool will delete old package $2, then 'go install' any package $3 to $1.
330
374
define go-install-tool
331
375
@[ -f $(1 ) ]|| { \
0 commit comments