Skip to content

Commit 006ed80

Browse files
asergeant01davidgrun
authored andcommitted
Escape file paths in Makefile (#482)
1 parent 187c28a commit 006ed80

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ helm: manifests kubebuilder
247247
## Location to install dependencies to
248248
LOCALBIN ?= $(shell pwd)/bin
249249
$(LOCALBIN):
250-
mkdir -p $(LOCALBIN)
250+
mkdir -p "$(LOCALBIN)"
251251

252252
CURL_RETRIES=3
253253

@@ -289,7 +289,7 @@ $(KUSTOMIZE): $(LOCALBIN)
289289
.PHONY: kubectl
290290
kubectl: $(KUBECTL) ## Download kubectl locally if necessary.
291291
$(KUBECTL): $(LOCALBIN)
292-
curl --retry $(CURL_RETRIES) -fsL https://dl.k8s.io/release/v$(ENVTEST_K8S_VERSION)/bin/$(GOOS)/$(GOARCH)/kubectl -o $(KUBECTL)
292+
curl --retry $(CURL_RETRIES) -fsL https://dl.k8s.io/release/v$(ENVTEST_K8S_VERSION)/bin/$(GOOS)/$(GOARCH)/kubectl -o "$(KUBECTL)"
293293
ln -sf "$(KUBECTL)" "$(KUBECTL_BIN)"
294294
chmod +x "$(KUBECTL_BIN)" "$(KUBECTL)"
295295

@@ -302,7 +302,7 @@ $(CONTROLLER_GEN): $(LOCALBIN)
302302
.PHONY: setup-envtest
303303
setup-envtest: envtest ## Download the binaries required for ENVTEST in the local bin directory.
304304
@echo "Setting up envtest binaries for Kubernetes version $(ENVTEST_K8S_VERSION)..."
305-
@$(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path || { \
305+
@"$(ENVTEST)" use $(ENVTEST_K8S_VERSION) --bin-dir "$(LOCALBIN)" -p path || { \
306306
echo "Error: Failed to set up envtest binaries for version $(ENVTEST_K8S_VERSION)."; \
307307
exit 1; \
308308
}
@@ -333,6 +333,7 @@ $(KUBEBUILDER): $(LOCALBIN)
333333
$(call go-install-tool,$(KUBEBUILDER),sigs.k8s.io/kubebuilder/v4,$(KUBEBUILDER_VERSION))
334334

335335
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
336+
# Note: All paths are quoted to work in directories containing spaces or parentheses.
336337
# $1 - target path with name of binary
337338
# $2 - package url which can be installed
338339
# $3 - specific version of package
@@ -341,11 +342,11 @@ define go-install-tool
341342
set -e; \
342343
package=$(2)@$(3) ;\
343344
echo "Downloading $${package}" ;\
344-
rm -f $(1) || true ;\
345-
GOBIN=$(LOCALBIN) go install $${package} ;\
346-
mv $(1) $(1)-$(3) ;\
345+
rm -f "$(1)" || true ;\
346+
GOBIN="$(LOCALBIN)" go install "$${package}" ;\
347+
mv "$(1)" "$(1)-$(3)" ;\
347348
} ;\
348-
ln -sf $(1)-$(3) $(1)
349+
ln -sf "$(1)-$(3)" "$(1)"
349350
endef
350351

351352
## --------------------------------------

0 commit comments

Comments
 (0)