Skip to content

Commit 221a944

Browse files
nixpanicopenshift-cherrypick-robot
authored andcommitted
build: enable inclusion of differently versioned container-images in the bundle
In case the *_IMG variables can contain a full qualified container-image resource (includes a ":"), the container-images should not use the TAG valued. The :TAG option will only be added if no predefined version is passed. Signed-off-by: Niels de Vos <ndevos@redhat.com>
1 parent 5658ffd commit 221a944

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

Makefile

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ BUNDLE_IMG ?= quay.io/csiaddons/k8s-bundle
77
# set TAG to a release for consumption in the bundle
88
TAG ?= latest
99

10+
# In case the *_IMG variables can contain a full qualified container-image
11+
# resource (includes a ":"), the container-images should not use the TAG
12+
# valued. The :TAG option will only be added if no predefined version is
13+
# passed.
14+
ifneq (findstring $(CONTROLLER_IMG),:)
15+
CONTROLLER_IMG := $(CONTROLLER_IMG):$(TAG)
16+
endif
17+
18+
ifneq (findstring $(SIDECAR_IMG),:)
19+
SIDECAR_IMG := $(SIDECAR_IMG):$(TAG)
20+
endif
21+
22+
ifneq (findstring $(BUNDLE_IMG),:)
23+
BUNDLE_IMG := $(BUNDLE_IMG):$(TAG)
24+
endif
25+
1026
# the PACKAGE_NAME is included in the bundle/CSV and is used in catalogsources
1127
# for operators (like OperatorHub.io). Products that include the CSI-Addons
1228
# bundle should use a different PACKAGE_NAME to prevent conflicts.
@@ -72,7 +88,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
7288

7389
.PHONY: bundle
7490
bundle: kustomize operator-sdk
75-
cd config/manager && $(KUSTOMIZE) edit set image controller=$(CONTROLLER_IMG):$(TAG) $(KUSTOMIZE_RBAC_PROXY)
91+
cd config/manager && $(KUSTOMIZE) edit set image controller=$(CONTROLLER_IMG) $(KUSTOMIZE_RBAC_PROXY)
7692
$(KUSTOMIZE) build config/default | $(OPERATOR_SDK) generate bundle --manifests --metadata --package=$(PACKAGE_NAME) $(BUNDLE_VERSION)
7793
mkdir -p ./bundle/tests/scorecard && $(KUSTOMIZE) build config/scorecard --output=./bundle/tests/scorecard/config.yaml
7894

@@ -114,27 +130,27 @@ run: manifests generate fmt vet ## Run a controller from your host.
114130

115131
.PHONY: docker-build
116132
docker-build: test ## Build docker image with the manager.
117-
docker build -t ${CONTROLLER_IMG}:${TAG} .
133+
docker build -t ${CONTROLLER_IMG} .
118134

119135
.PHONY: docker-push
120136
docker-push: ## Push docker image with the manager.
121-
docker push ${CONTROLLER_IMG}:${TAG}
137+
docker push ${CONTROLLER_IMG}
122138

123139
.PHONY: docker-build-sidecar
124140
docker-build-sidecar:
125-
docker build -f ./build/Containerfile.sidecar -t ${SIDECAR_IMG}:${TAG} .
141+
docker build -f ./build/Containerfile.sidecar -t ${SIDECAR_IMG} .
126142

127143
.PHONY: docker-push-sidecar
128144
docker-push-sidecar:
129-
docker push ${SIDECAR_IMG}:${TAG}
145+
docker push ${SIDECAR_IMG}
130146

131147
.PHONY: docker-build-bundle
132148
docker-build-bundle: bundle
133-
docker build -f ./bundle.Dockerfile -t ${BUNDLE_IMG}:${TAG} .
149+
docker build -f ./bundle.Dockerfile -t ${BUNDLE_IMG} .
134150

135151
.PHONY: docker-push-bundle
136152
docker-push-bundle:
137-
docker push ${BUNDLE_IMG}:${TAG}
153+
docker push ${BUNDLE_IMG}
138154

139155
##@ Deployment
140156

@@ -152,7 +168,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
152168

153169
.PHONY: deploy
154170
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
155-
cd config/manager && $(KUSTOMIZE) edit set image controller=${CONTROLLER_IMG}:${TAG} $(KUSTOMIZE_RBAC_PROXY)
171+
cd config/manager && $(KUSTOMIZE) edit set image controller=${CONTROLLER_IMG} $(KUSTOMIZE_RBAC_PROXY)
156172
$(KUSTOMIZE) build config/default | kubectl apply -f -
157173

158174
.PHONY: undeploy

0 commit comments

Comments
 (0)