From 7f2889f43dbecfaad0c8520c7334eab929d57f9a Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Thu, 6 Jul 2023 10:12:25 -0500 Subject: [PATCH] Handle stale kustomize in bin dir. (#52) Signed-off-by: Dean Roehrich --- Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0d482ff..b1dbcfa 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Copyright 2021, 2022 Hewlett Packard Enterprise Development LP +# Copyright 2021-2023 Hewlett Packard Enterprise Development LP # Other additional copyright holders may be indicated within. # # The entirety of this work is licensed under the Apache License, @@ -90,6 +90,9 @@ helm-version: .version ## Updates the Helm values.yaml with new version clean: rm -f .version +.PHONY: clean-bin +clean-bin: + rm -rf $(LOCALBIN) ## Location to install dependencies to LOCALBIN ?= $(shell pwd)/bin @@ -104,6 +107,8 @@ KUSTOMIZE_VERSION ?= v4.5.7 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" .PHONY: kustomize -kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. -$(KUSTOMIZE): $(LOCALBIN) - test -s $(LOCALBIN)/kustomize || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); } +kustomize: $(LOCALBIN) ## Download kustomize locally if necessary. + if [[ ! -s $(LOCALBIN)/kustomize || $$($(LOCALBIN)/kustomize version | awk '{print $$1}' | awk -F/ '{print $$2}') != $(KUSTOMIZE_VERSION) ]]; then \ + rm -f $(LOCALBIN)/kustomize && \ + { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }; \ + fi