Skip to content

Commit 288a57b

Browse files
authored
Improves makefile to add check-tools target (#265)
* makefile: various improvements * Address comments
1 parent 2263f15 commit 288a57b

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

Makefile

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# BUNDLE_VERSION defines the project version for the bundle.
32
# Update this value when you upgrade the version of your project.
43
# To re-generate a bundle for another specific version without changing the standard setup, you can:
@@ -193,18 +192,25 @@ local-run: build
193192
##@ Build
194193
GO=GO111MODULE=on CGO_ENABLED=1 go
195194

195+
# Check for required tools
196+
.PHONY: check-tools
197+
check-tools:
198+
@command -v go >/dev/null 2>&1 || { echo "WARNING: go is not installed. Please install it to avoid issues."; }
199+
@command -v $(CONTAINER_ENGINE) >/dev/null 2>&1 || { echo "WARNING: $(CONTAINER_ENGINE) is not installed. Please install it to avoid issues."; }
200+
@command -v kubectl >/dev/null 2>&1 || { echo "WARNING: kubectl is not installed. Please install it to avoid issues."; }
201+
196202
build-operator: ## Build operator binary, no additional checks or code generation
197203
@GOFLAGS="-mod=vendor" source hack/go-fips.sh && $(GO) build $(GOBUILD_VERSION_ARGS) -o $(BIN)
198204

199-
build: generate fmt vet build-operator ## Build operator binary.
205+
build: check-tools generate fmt vet build-operator ## Build operator binary.
200206

201-
run: manifests generate fmt vet ## Run a controller from your host.
207+
run: check-tools manifests generate fmt vet ## Run a controller from your host.
202208
go run $(PACKAGE)
203209

204-
image-build: ## Build container image with the operator.
210+
image-build: check-tools ## Build container image with the operator.
205211
$(CONTAINER_ENGINE) build -t ${IMG} .
206212

207-
image-push: ## Push container image with the operator.
213+
image-push: check-tools ## Push container image with the operator.
208214
$(CONTAINER_ENGINE) push ${IMG} ${CONTAINER_PUSH_ARGS}
209215

210216
##@ Deployment
@@ -217,26 +223,26 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
217223
$(KUSTOMIZE) build config/default | kubectl delete -f -
218224

219225
.PHONY: bundle
220-
bundle: $(OPERATOR_SDK_BIN) manifests
226+
bundle: check-tools $(OPERATOR_SDK_BIN) manifests
221227
$(OPERATOR_SDK_BIN) generate kustomize manifests -q
222228
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
223229
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK_BIN) generate bundle -q --version $(BUNDLE_VERSION) $(BUNDLE_METADATA_OPTS)
224230
$(OPERATOR_SDK_BIN) bundle validate $(BUNDLE_DIR)
225231

226232
.PHONY: bundle-image-build
227-
bundle-image-build: bundle
233+
bundle-image-build: check-tools bundle
228234
$(CONTAINER_ENGINE) build -t ${BUNDLE_IMG} -f bundle.Dockerfile .
229235

230236
.PHONY: bundle-image-push
231-
bundle-image-push:
237+
bundle-image-push: check-tools
232238
$(CONTAINER_ENGINE) push ${BUNDLE_IMG}
233239

234240
.PHONY: index-image-build
235-
index-image-build: opm
241+
index-image-build: check-tools opm
236242
$(OPM) index add -c $(CONTAINER_ENGINE) --bundles ${BUNDLE_IMG} --tag ${INDEX_IMG}
237243

238244
.PHONY: index-image-push
239-
index-image-push:
245+
index-image-push: check-tools
240246
$(CONTAINER_ENGINE) push ${INDEX_IMG}
241247

242248
OPM=$(BIN_DIR)/opm
@@ -301,6 +307,7 @@ $(HELM_BIN):
301307
mkdir -p $(BIN_DIR)
302308
hack/helm.sh $(HELM_BIN)
303309

310+
.PHONY: clean
304311
clean:
305312
go clean
306313
rm -f $(BIN)

0 commit comments

Comments
 (0)