@@ -59,7 +59,16 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
5959
6060# BUNDLE_IMAGE defines the image:tag used for the bundle.
6161# You can use it as an arg. (E.g make bundle-build BUNDLE_IMAGE=<some-registry>/<project-name-bundle>:<tag>)
62- BUNDLE_IMAGE ?= gpu-operator-bundle:$(VERSION )
62+ BUNDLE_IMAGE_NAME ?= gpu-operator-bundle
63+ BUNDLE_VERSION ?= $(VERSION )
64+ BUNDLE_GIT_TAG ?= $(GIT_COMMIT )
65+ OPERATOR_IMAGE_NAME ?= gpu-operator
66+ OPERATOR_VERSION ?= $(VERSION )
67+ BUNDLE_CSV_FILE ?= bundle/manifests/gpu-operator-certified.clusterserviceversion.yaml
68+
69+
70+ BUNDLE_IMAGE = $(BUNDLE_IMAGE_NAME ) :$(BUNDLE_VERSION )
71+ BUNDLE_IMAGE_GIT := $(if $(BUNDLE_GIT_TAG ) ,$(BUNDLE_IMAGE_NAME ) :$(BUNDLE_GIT_TAG ) )
6372
6473# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
6574ifeq (,$(shell go env GOBIN) )
@@ -126,16 +135,27 @@ bundle: manifests install-tools
126135 $(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
127136 operator-sdk bundle validate ./bundle
128137
138+ # Update the bundle CSV file with operator image tag
139+ update-bundle-csv :
140+ @echo " Updating GPU operator image in $( BUNDLE_CSV_FILE) to $( OPERATOR_IMAGE_NAME) :$( OPERATOR_VERSION) "
141+ @sed -i.bak -e ' s|ghcr.io/nvidia/gpu-operator:[^ "]*|$(OPERATOR_IMAGE_NAME):$(OPERATOR_VERSION)|g' $(BUNDLE_CSV_FILE )
142+ @rm -f $(BUNDLE_CSV_FILE ) .bak
143+ @echo " Bundle CSV updated successfully"
144+
129145# Build the bundle image.
130- build-bundle-image :
146+ build-bundle-image : update-bundle-csv
131147 $(DOCKER ) build \
132148 --build-arg DEFAULT_CHANNEL=$(DEFAULT_CHANNEL ) \
133149 --build-arg GIT_COMMIT=$(GIT_COMMIT ) \
134- -f docker/bundle.Dockerfile -t $(BUNDLE_IMAGE ) .
150+ -f docker/bundle.Dockerfile \
151+ -t $(BUNDLE_IMAGE ) \
152+ $(if $(BUNDLE_IMAGE_GIT ) ,-t $(BUNDLE_IMAGE_GIT ) ) \
153+ .
135154
136155# Push the bundle image.
137156push-bundle-image : build-bundle-image
138157 $(DOCKER ) push $(BUNDLE_IMAGE )
158+ $(if $(BUNDLE_IMAGE_GIT ) ,$(DOCKER ) push $(BUNDLE_IMAGE_GIT ) )
139159
140160# Define local and dockerized golang targets
141161
0 commit comments