11# Default environment is default
2- ENVIRONMENT =${1:-default}
2+ ENVIRONMENT ?= ${1}
3+ ${ENVIRONMENT} :
4+ ENVIRONMENT = default
35
46# VERSION defines the project version for the bundle.
57# Update this value when you upgrade the version of your project.
@@ -25,7 +27,7 @@ NAMESPACE ?= "splunk-operator"
2527# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate,fast,stable)
2628# - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable")
2729ifneq ($(origin CHANNELS ) , undefined)
28- BUNDLE_CHANNELS := --channels=$( CHANNELS )
30+ BUNDLE_CHANNELS := --channels=${ CHANNELS}
2931endif
3032
3133# DEFAULT_CHANNEL defines the default channel used in the bundle.
3436# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable)
3537# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable")
3638ifneq ($(origin DEFAULT_CHANNEL ) , undefined)
37- BUNDLE_DEFAULT_CHANNEL := --default-channel=$( DEFAULT_CHANNEL )
39+ BUNDLE_DEFAULT_CHANNEL := --default-channel=${ DEFAULT_CHANNEL}
3840endif
39- BUNDLE_METADATA_OPTS ?= $( BUNDLE_CHANNELS ) $( BUNDLE_DEFAULT_CHANNEL )
41+ BUNDLE_METADATA_OPTS ?= ${ BUNDLE_CHANNELS} ${ BUNDLE_DEFAULT_CHANNEL}
4042
4143# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
4244# This variable is used to construct full image tags for bundle and catalog images.
@@ -47,7 +49,7 @@ IMAGE_TAG_BASE ?= splunk/splunk-operator
4749
4850# BUNDLE_IMG defines the image:tag used for the bundle.
4951# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
50- BUNDLE_IMG ?= $( IMAGE_TAG_BASE ) -bundle:v$( VERSION )
52+ BUNDLE_IMG ?= ${ IMAGE_TAG_BASE} -bundle:v${ VERSION}
5153
5254# Image URL to use all building/pushing image targets
5355IMG ?= controller:latest
@@ -129,7 +131,7 @@ vet: setup/ginkgo ## Run go vet against code.
129131 go vet ./...
130132
131133test : manifests generate fmt vet envtest # # Run tests.
132- KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( LOCALBIN) -p path) " ginkgo --junit-report=unit_test.xml --output-dir=` pwd` -vv --trace --keep-going --timeout=3h --cover --covermode=count --coverprofile=coverage.out ./pkg/splunk/common ./pkg/splunk/enterprise ./pkg/splunk/controller ./pkg/splunk/client ./pkg/splunk/util ./controllers
134+ KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use ${ ENVTEST_K8S_VERSION} --bin-dir $( LOCALBIN) -p path) " ginkgo --junit-report=unit_test.xml --output-dir=` pwd` -vv --trace --keep-going --timeout=3h --cover --covermode=count --coverprofile=coverage.out ./pkg/splunk/common ./pkg/splunk/enterprise ./pkg/splunk/controller ./pkg/splunk/client ./pkg/splunk/util ./controllers
133135
134136
135137# #@ Build
@@ -159,20 +161,20 @@ BASE_IMAGE ?= registry.access.redhat.com/ubi8/ubi-minimal@sha256
159161BASE_IMAGE_VERSION ?= b2a1bec3dfbc7a14a1d84d98934dfe8fdde6eb822a211286601cf109cbccb075
160162
161163docker-buildx :
162- @if [ -z " $( IMG) " ]; then \
164+ @if [ -z " ${ IMG} " ]; then \
163165 echo " Error: IMG is a mandatory argument. Usage: make docker-buildx IMG=<image_name> ...." ; \
164166 exit 1; \
165167 fi ; \
166- if echo " $( BASE_IMAGE) " | grep -q " distroless" ; then \
168+ if echo " ${ BASE_IMAGE} " | grep -q " distroless" ; then \
167169 DOCKERFILE=" Dockerfile.distroless" ; \
168- BUILD_TAG=" $( IMG) -distroless" ; \
170+ BUILD_TAG=" ${ IMG} -distroless" ; \
169171 else \
170172 DOCKERFILE=" Dockerfile" ; \
171- BUILD_TAG=" $( IMG) " ; \
173+ BUILD_TAG=" ${ IMG} " ; \
172174 fi ; \
173- docker buildx build --push --platform=" $( PLATFORMS) " \
174- --build-arg BASE_IMAGE=" $( BASE_IMAGE) " \
175- --build-arg BASE_IMAGE_VERSION=" $( BASE_IMAGE_VERSION) " \
175+ docker buildx build --push --platform=" ${ PLATFORMS} " \
176+ --build-arg BASE_IMAGE=" ${ BASE_IMAGE} " \
177+ --build-arg BASE_IMAGE_VERSION=" ${ BASE_IMAGE_VERSION} " \
176178 --tag " $$ BUILD_TAG" -f " $$ DOCKERFILE" .
177179
178180
@@ -182,23 +184,23 @@ install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~
182184 $(KUSTOMIZE ) build config/crd | kubectl apply --server-side --force-conflicts -f -
183185
184186uninstall : manifests kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
185- $(KUSTOMIZE ) build config/crd | kubectl delete --ignore-not-found=$( ignore-not-found ) -f -
187+ $(KUSTOMIZE ) build config/crd | kubectl delete --ignore-not-found=${ ignore-not-found} -f -
186188
187189deploy : manifests kustomize uninstall # # Deploy controller to the K8s cluster specified in ~/.kube/config.
188- $(SED ) " s/namespace: splunk-operator/namespace: ${NAMESPACE} /g" config/$( ENVIRONMENT ) /kustomization.yaml
189- $(SED ) " s/value: WATCH_NAMESPACE_VALUE/value: \" ${WATCH_NAMESPACE} \" /g" config/$( ENVIRONMENT ) /kustomization.yaml
190- $(SED ) " s|SPLUNK_ENTERPRISE_IMAGE|${SPLUNK_ENTERPRISE_IMAGE} |g" config/$( ENVIRONMENT ) /kustomization.yaml
190+ $(SED ) " s/namespace: splunk-operator/namespace: ${NAMESPACE} /g" config/${ ENVIRONMENT} /kustomization.yaml
191+ $(SED ) " s/value: WATCH_NAMESPACE_VALUE/value: \" ${WATCH_NAMESPACE} \" /g" config/${ ENVIRONMENT} /kustomization.yaml
192+ $(SED ) " s|SPLUNK_ENTERPRISE_IMAGE|${SPLUNK_ENTERPRISE_IMAGE} |g" config/${ ENVIRONMENT} /kustomization.yaml
191193 cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
192- RELATED_IMAGE_SPLUNK_ENTERPRISE=${SPLUNK_ENTERPRISE_IMAGE} WATCH_NAMESPACE=${WATCH_NAMESPACE} $(KUSTOMIZE ) build config/$( ENVIRONMENT ) | kubectl apply --server-side --force-conflicts -f -
193- $(SED ) " s/namespace: ${NAMESPACE} /namespace: splunk-operator/g" config/$( ENVIRONMENT ) /kustomization.yaml
194- $(SED ) " s/value: \" ${WATCH_NAMESPACE} \" /value: WATCH_NAMESPACE_VALUE/g" config/$( ENVIRONMENT ) /kustomization.yaml
195- $(SED ) " s|${SPLUNK_ENTERPRISE_IMAGE} |SPLUNK_ENTERPRISE_IMAGE|g" config/$( ENVIRONMENT ) /kustomization.yaml
194+ RELATED_IMAGE_SPLUNK_ENTERPRISE=${SPLUNK_ENTERPRISE_IMAGE} WATCH_NAMESPACE=${WATCH_NAMESPACE} $(KUSTOMIZE ) build config/${ ENVIRONMENT} | kubectl apply --server-side --force-conflicts -f -
195+ $(SED ) " s/namespace: ${NAMESPACE} /namespace: splunk-operator/g" config/${ ENVIRONMENT} /kustomization.yaml
196+ $(SED ) " s/value: \" ${WATCH_NAMESPACE} \" /value: WATCH_NAMESPACE_VALUE/g" config/${ ENVIRONMENT} /kustomization.yaml
197+ $(SED ) " s|${SPLUNK_ENTERPRISE_IMAGE} |SPLUNK_ENTERPRISE_IMAGE|g" config/${ ENVIRONMENT} /kustomization.yaml
196198
197199undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config.
198- $(KUSTOMIZE ) build config/$( ENVIRONMENT ) | kubectl delete -f -
200+ $(KUSTOMIZE ) build config/${ ENVIRONMENT} | kubectl delete -f -
199201
200202# # Location to install dependencies to
201- LOCALBIN ?= $(shell pwd) /bin
203+ LOCALBIN ?= " $(shell pwd) /bin"
202204$(LOCALBIN ) :
203205 mkdir -p $(LOCALBIN )
204206
@@ -209,13 +211,13 @@ CONTROLLER_TOOLS_VERSION ?= v0.16.1
209211CONTROLLER_GEN = $(LOCALBIN ) /controller-gen
210212controller-gen : $(CONTROLLER_GEN ) # # Download controller-gen locally if necessary.
211213$(CONTROLLER_GEN ) : $(LOCALBIN )
212- test -s $(LOCALBIN ) /controller-gen || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$( CONTROLLER_TOOLS_VERSION )
214+ test -s $(LOCALBIN ) /controller-gen || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-tools/cmd/controller-gen@${ CONTROLLER_TOOLS_VERSION}
213215
214216KUSTOMIZE = $(LOCALBIN ) /kustomize
215217KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
216218kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
217219$(KUSTOMIZE ) : $(LOCALBIN )
218- test -s $(LOCALBIN ) /kustomize || curl -s $(KUSTOMIZE_INSTALL_SCRIPT ) | bash -s -- $(subst v,,$( KUSTOMIZE_VERSION ) ) $(LOCALBIN )
220+ test -s $(LOCALBIN ) /kustomize || curl -s $(KUSTOMIZE_INSTALL_SCRIPT ) | bash -s -- $(subst v,,${ KUSTOMIZE_VERSION} ) $(LOCALBIN )
219221
220222ENVTEST = $(LOCALBIN ) /setup-envtest
221223envtest : $(ENVTEST ) # # Download envtest-setup locally if necessary.
@@ -230,19 +232,19 @@ bundle: manifests kustomize
230232 cp config/default/kustomization-cluster.yaml config/default/kustomization.yaml
231233 $(SED ) " s/namespace: splunk-operator/namespace: ${NAMESPACE} /g" config/default/kustomization.yaml
232234 $(SED ) " s|SPLUNK_ENTERPRISE_IMAGE|${SPLUNK_ENTERPRISE_IMAGE} |g" config/default/kustomization.yaml
233- cd config/manager && $(KUSTOMIZE ) edit set image controller=$( IMG )
234- $(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle $( BUNDLE_GEN_FLAGS )
235+ cd config/manager && $(KUSTOMIZE ) edit set image controller=${ IMG}
236+ $(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle ${ BUNDLE_GEN_FLAGS}
235237 operator-sdk bundle validate ./bundle
236238 operator-sdk bundle validate bundle --select-optional suite=operatorframework
237239 cp bundle/manifests/enterprise.splunk.com* helm-chart/splunk-operator/crds
238240
239241.PHONY : bundle-build
240242bundle-build : # # Build the bundle image.
241- docker build -f bundle.Dockerfile -t $( BUNDLE_IMG ) .
243+ docker build -f bundle.Dockerfile -t ${ BUNDLE_IMG} .
242244
243245.PHONY : bundle-push
244246bundle-push : # # Push the bundle image.
245- $(MAKE ) docker-push IMG=$( BUNDLE_IMG )
247+ $(MAKE ) docker-push IMG=${ BUNDLE_IMG}
246248
247249.PHONY : opm
248250OPM = ./bin/opm
@@ -263,35 +265,35 @@ endif
263265
264266# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
265267# These images MUST exist in a registry and be pull-able.
266- BUNDLE_IMGS ?= $( BUNDLE_IMG )
268+ BUNDLE_IMGS ?= ${ BUNDLE_IMG}
267269
268270# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
269- CATALOG_IMG ?= $( IMAGE_TAG_BASE ) -catalog:v$( VERSION )
271+ CATALOG_IMG ?= ${ IMAGE_TAG_BASE} -catalog:v${ VERSION}
270272
271273# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
272274ifneq ($(origin CATALOG_BASE_IMG ) , undefined)
273- FROM_INDEX_OPT := --from-index $( CATALOG_BASE_IMG )
275+ FROM_INDEX_OPT := --from-index ${ CATALOG_BASE_IMG}
274276endif
275277
276278# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
277279# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
278280# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
279281.PHONY : catalog-build
280282catalog-build : opm # # Build a catalog image.
281- $(OPM ) index add --container-tool docker --mode semver --tag $( CATALOG_IMG ) --bundles $( BUNDLE_IMGS ) $( FROM_INDEX_OPT )
283+ $(OPM ) index add --container-tool docker --mode semver --tag ${ CATALOG_IMG} --bundles ${ BUNDLE_IMGS} ${ FROM_INDEX_OPT}
282284
283285# Push the catalog image.
284286.PHONY : catalog-push
285287catalog-push : # # Push a catalog image.
286- $(MAKE ) docker-push IMG=$( CATALOG_IMG )
288+ $(MAKE ) docker-push IMG=${ CATALOG_IMG}
287289
288290
289291
290292.PHONY : code/sec
291- code/sec : $GOBIN/gosec # # Run gosec
293+ code/sec : $( GOBIN ) /gosec # # Run gosec
292294 gosec -severity medium --confidence medium -quiet ./...
293295
294- $GOBIN/gosec :
296+ $( GOBIN ) /gosec :
295297 go get -u github.com/securego/gosec/cmd/gosec
296298
297299.PHONY : cluster-up
@@ -367,8 +369,8 @@ generate-artifacts: generate-artifacts-namespace generate-artifacts-cluster
367369GO_DOWNLOAD_URL =https://go.dev/dl/go1.17.7.darwin-amd64.pkg
368370export OPERATOR_SDK_DL_URL=https ://github.com/operator-framework/operator-sdk/releases/download/v1.17.0
369371OPERATOR_SDK_DOWNLOAD_URL =curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
370- MINIKUBE_DOWNLOAD_URL =https://storage.googleapis.com/minikube/releases/latest/minikube-$( OS ) - $( ARCH )
371- KUBECTL_DOWNLOAD_URL ="https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt ) /bin/$( OS ) / $( ARCH ) /kubectl"
372+ MINIKUBE_DOWNLOAD_URL =https://storage.googleapis.com/minikube/releases/latest/minikube-${OS}-${ ARCH}
373+ KUBECTL_DOWNLOAD_URL ="https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt ) /bin/${OS}/${ ARCH} /kubectl"
372374
373375.PHONY : setup/devsetup
374376setup/devsetup :
@@ -384,7 +386,7 @@ setup/devsetup:
384386
385387clean : stop_clair_scanner
386388 @rm -rf ./build/_output
387- @docker rmi $( IMG ) || true
389+ @docker rmi ${ IMG} || true
388390 @rm -f clair-scanner
389391 @rm -rf clair-scanner-logs
390392
0 commit comments