|
| 1 | + |
| 2 | +VERSION ?= 0.0.1 |
| 3 | + |
| 4 | +# CHANNELS define the bundle channels used in the bundle. |
| 5 | +# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") |
| 6 | +# To re-generate a bundle for other specific channels without changing the standard setup, you can: |
| 7 | +# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate,fast,stable) |
| 8 | +# - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable") |
| 9 | +ifneq ($(origin CHANNELS), undefined) |
| 10 | +BUNDLE_CHANNELS := --channels=$(CHANNELS) |
| 11 | +endif |
| 12 | + |
| 13 | +# DEFAULT_CHANNEL defines the default channel used in the bundle. |
| 14 | +# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable") |
| 15 | +# To re-generate a bundle for any other default channel without changing the default setup, you can: |
| 16 | +# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable) |
| 17 | +# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable") |
| 18 | +ifneq ($(origin DEFAULT_CHANNEL), undefined) |
| 19 | +BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) |
| 20 | +endif |
| 21 | +BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) |
| 22 | + |
| 23 | +# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images. |
| 24 | +# This variable is used to construct full image tags for bundle and catalog images. |
| 25 | +# |
| 26 | +# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both |
| 27 | +# projectnessie.org/nessie-operator-bundle:$VERSION and projectnessie.org/nessie-operator-catalog:$VERSION. |
| 28 | +IMAGE_TAG_BASE ?= ghcr.io/projectnessie/nessie-operator |
| 29 | + |
| 30 | +# BUNDLE_IMG defines the image:tag used for the bundle. |
| 31 | +# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>) |
| 32 | +BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION) |
| 33 | + |
| 34 | +# Image URL to use all building/pushing image targets |
| 35 | +IMG ?= $(IMAGE_TAG_BASE):latest |
| 36 | + |
| 37 | +PULL_POLICY ?= Always |
| 38 | +PLATFORM ?= linux/amd64 |
| 39 | + |
| 40 | +all: docker-build |
| 41 | + |
| 42 | +##@ General |
| 43 | + |
| 44 | +# The help target prints out all targets with their descriptions organized |
| 45 | +# beneath their categories. The categories are represented by '##@' and the |
| 46 | +# target descriptions by '##'. The awk commands is responsible for reading the |
| 47 | +# entire set of makefiles included in this invocation, looking for lines of the |
| 48 | +# file as xyz: ## something, and then pretty-format the target and help. Then, |
| 49 | +# if there's a line with ##@ something, that gets pretty-printed as a category. |
| 50 | +# More info on the usage of ANSI control characters for terminal formatting: |
| 51 | +# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters |
| 52 | +# More info on the awk command: |
| 53 | +# http://linuxcommand.org/lc3_adv_awk.php |
| 54 | + |
| 55 | +help: ## Display this help. |
| 56 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
| 57 | + |
| 58 | +##@ Build |
| 59 | + |
| 60 | +docker-build: ## Build docker image with the manager. |
| 61 | + ../gradlew --no-build-cache :nessie-operator:spotlessApply :nessie-operator:clean :nessie-operator:build -x check \ |
| 62 | + -Dquarkus.container-image.image=${IMG} \ |
| 63 | + -Dquarkus.jib.platforms=${PLATFORM} \ |
| 64 | + -Dquarkus.kubernetes.image-pull-policy=${PULL_POLICY} |
| 65 | + |
| 66 | +docker-push: ## Build and push docker image with the manager. |
| 67 | + ../gradlew --no-build-cache :nessie-operator:spotlessApply :nessie-operator:clean :nessie-operator:build -x check \ |
| 68 | + -Dquarkus.container-image.push=true \ |
| 69 | + -Dquarkus.container-image.image=${IMG} \ |
| 70 | + -Dquarkus.jib.platforms=${PLATFORM} \ |
| 71 | + -Dquarkus.kubernetes.image-pull-policy=${PULL_POLICY} |
| 72 | + |
| 73 | +##@ Deployment |
| 74 | + |
| 75 | +install: ## Install CRDs into the K8s cluster specified in ~/.kube/config. |
| 76 | + @$(foreach file, $(wildcard build/kubernetes/*-v1.yml), kubectl apply -f $(file);) |
| 77 | + |
| 78 | +uninstall: ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. |
| 79 | + @$(foreach file, $(wildcard build/kubernetes/*-v1.yml), kubectl delete -f $(file);) |
| 80 | + |
| 81 | +deploy: ## Deploy controller to the K8s cluster specified in ~/.kube/config. |
| 82 | + kubectl apply -f build/kubernetes/kubernetes.yml |
| 83 | + |
| 84 | +undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. |
| 85 | + kubectl delete -f build/kubernetes/kubernetes.yml |
| 86 | + |
| 87 | +##@Bundle |
| 88 | +.PHONY: bundle |
| 89 | +bundle: ## Generate bundle manifests and metadata, then validate generated files. |
| 90 | +## marker |
| 91 | + cat build/kubernetes/nessies.nessie.projectnessie.org-v1alpha1.yml target/kubernetes/kubernetes.yml | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) |
| 92 | + operator-sdk bundle validate ./bundle |
| 93 | + |
| 94 | +.PHONY: bundle-build |
| 95 | +bundle-build: ## Build the bundle image. |
| 96 | + docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . |
| 97 | + |
| 98 | +.PHONY: bundle-push |
| 99 | +bundle-push: ## Push the bundle image. |
| 100 | + docker push $(BUNDLE_IMG) |
0 commit comments