Skip to content

Commit

Permalink
Add build parameters
Browse files Browse the repository at this point in the history
This commit makes it easy to change the names of the build artifacts.
Mainly,

1. Image name
2. Image repository
3. Image registry
4. OLM Bundle names

One side effect is that IMAGE_TAG_BASE is not read as a ENV and is
always constructed using the name, repo and registry.

Signed-off-by: Raghavendra Talur <raghavendra.talur@gmail.com>
  • Loading branch information
raghavendra-talur authored and ShyamsundarR committed Aug 12, 2021
1 parent ebbb23c commit dc36bc6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
30 changes: 17 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,24 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
# This variable is used to construct full image tags for bundle and catalog images.
# IMAGE_TAG defines the tag name for the image, and is used to construct full image tags for bundle
# and catalog images as well.
#
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# example.com/tmp-sdk-bundle:$IMAGE_TAG and example.com/tmp-sdk-catalog:$IMAGE_TAG.
IMAGE_TAG_BASE ?= quay.io/ramendr/ramen
IMAGE_REGISTRY ?= quay.io
IMAGE_REPOSITORY ?= ramendr
IMAGE_NAME ?= ramen
IMAGE_TAG ?= latest
IMAGE_TAG_BASE = $(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME)

HUB_NAME ?= $(IMAGE_NAME)-hub
ifeq (dr,$(findstring dr,$(IMAGE_NAME)))
DRCLUSTER_NAME = $(IMAGE_NAME)-cluster
BUNDLE_IMG_DRCLUSTER = $(IMAGE_TAG_BASE)-cluster-operator-bundle:$(IMAGE_TAG)
else
DRCLUSTER_NAME = $(IMAGE_NAME)-dr-cluster
BUNDLE_IMG_DRCLUSTER = $(IMAGE_TAG_BASE)-dr-cluster-operator-bundle:$(IMAGE_TAG)
endif



# BUNDLE_IMG defines the image:tag used for the bundle.
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
BUNDLE_IMG_HUB ?= $(IMAGE_TAG_BASE)-hub-operator-bundle:$(IMAGE_TAG)
BUNDLE_IMG_DRCLUSTER ?= $(IMAGE_TAG_BASE)-dr-cluster-operator-bundle:$(IMAGE_TAG)

# Image URL to use all building/pushing image targets
IMG ?= $(IMAGE_TAG_BASE)-operator:$(IMAGE_TAG)
Expand Down Expand Up @@ -216,7 +220,7 @@ bundle-push: bundle-hub-push bundle-dr-cluster-push ## Push all bundle images.
.PHONY: bundle-hub
bundle-hub: manifests kustomize operator-sdk ## Generate hub bundle manifests and metadata, then validate generated files.
cd config/hub/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build --load_restrictor none config/hub/manifests | $(OSDK) generate bundle -q --package=ramen-hub --overwrite --output-dir=config/hub/bundle --version $(VERSION) $(BUNDLE_METADATA_OPTS)
$(KUSTOMIZE) build --load_restrictor none config/hub/manifests/$(IMAGE_NAME) | $(OSDK) generate bundle -q --package=$(HUB_NAME) --overwrite --output-dir=config/hub/bundle --version $(VERSION) $(BUNDLE_METADATA_OPTS)
$(OSDK) bundle validate config/hub/bundle

.PHONY: bundle-hub-build
Expand All @@ -230,7 +234,7 @@ bundle-hub-push: ## Push the hub bundle image.
.PHONY: bundle-dr-cluster
bundle-dr-cluster: manifests kustomize operator-sdk ## Generate dr-cluster bundle manifests and metadata, then validate generated files.
cd config/dr_cluster/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build --load_restrictor none config/dr_cluster/manifests | $(OSDK) generate bundle -q --package=ramen-dr-cluster --overwrite --output-dir=config/dr_cluster/bundle --version $(VERSION) $(BUNDLE_METADATA_OPTS)
$(KUSTOMIZE) build --load_restrictor none config/dr_cluster/manifests/$(IMAGE_NAME) | $(OSDK) generate bundle -q --package=$(DRCLUSTER_NAME) --overwrite --output-dir=config/dr_cluster/bundle --version $(VERSION) $(BUNDLE_METADATA_OPTS)
$(OSDK) bundle validate config/dr_cluster/bundle

.PHONY: bundle-dr-cluster-build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# These resources constitute the fully configured set of manifests
# used to generate the 'manifests/' directory in a bundle.
resources:
- bases/ramen_hub.clusterserviceversion.yaml
- ../default
- ../samples
- ../../scorecard
- ../bases/ramen_dr_cluster.clusterserviceversion.yaml
- ../../default
- ../../samples
- ../../../scorecard

# [WEBHOOK] To enable webhooks, uncomment all the sections with [WEBHOOK] prefix.
# Do NOT uncomment sections with prefix [CERTMANAGER], as OLM does not support cert-manager.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# These resources constitute the fully configured set of manifests
# used to generate the 'manifests/' directory in a bundle.
resources:
- bases/ramen_dr_cluster.clusterserviceversion.yaml
- ../default
- ../samples
- ../../scorecard
- ../bases/ramen_hub.clusterserviceversion.yaml
- ../../default
- ../../samples
- ../../../scorecard

# [WEBHOOK] To enable webhooks, uncomment all the sections with [WEBHOOK] prefix.
# Do NOT uncomment sections with prefix [CERTMANAGER], as OLM does not support cert-manager.
Expand Down

0 comments on commit dc36bc6

Please sign in to comment.