@@ -31,9 +31,21 @@ REPO_URL ?= https://github.com/packethost/cluster-api-provider-packet
3131BUILDARCH ?= $(shell uname -m)
3232BUILDOS ?= $(shell uname -s | tr A-Z a-z)
3333
34- TEST_E2E_DIR := test/e2e
3534E2E_FOCUS := "functional tests"
3635
36+ # Directories.
37+ TOOLS_DIR := hack/tools
38+ TOOLS_BIN_DIR := $(TOOLS_DIR ) /bin
39+ BIN_DIR := bin
40+ TEST_E2E_DIR := test/e2e
41+
42+ # Binaries.
43+ KUSTOMIZE := $(TOOLS_BIN_DIR ) /kustomize
44+
45+ kustomize : $(KUSTOMIZE )
46+ $(KUSTOMIZE ) : $(TOOLS_DIR ) /go.mod # Build kustomize from tools folder.
47+ cd $(TOOLS_DIR ) ; go build -tags=tools -o $(BIN_DIR ) /kustomize sigs.k8s.io/kustomize/kustomize/v3
48+
3749# canonicalized names for host architecture
3850ifeq ($(BUILDARCH ) ,aarch64)
3951 BUILDARCH =arm64
@@ -201,16 +213,16 @@ run: generate fmt vet crds
201213
202214# Install CRDs into a cluster
203215install : crds
204- kustomize build config/crd | kubectl apply -f -
216+ $( KUSTOMIZE ) build config/crd | kubectl apply -f -
205217
206218# Uninstall CRDs from a cluster
207219uninstall : crds
208- kustomize build config/crd | kubectl delete -f -
220+ $( KUSTOMIZE ) build config/crd | kubectl delete -f -
209221
210222# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
211223deploy : crds
212- cd config/manager && kustomize edit set image controller=${IMG}
213- kustomize build config/default | kubectl apply -f -
224+ cd config/manager && $( KUSTOMIZE ) edit set image controller=${IMG}
225+ $( KUSTOMIZE ) build config/default | kubectl apply -f -
214226
215227# Generate manifests e.g. CRD, RBAC etc.
216228crds : controller-gen
@@ -291,7 +303,7 @@ ifeq (,$(VERSION))
291303endif
292304
293305
294- manifest : semver release-manifests release-clusterctl release-cluster-template
306+ manifest : kustomize semver release-manifests release-clusterctl release-cluster-template
295307
296308release :
297309 goreleaser release --rm-dist --snapshot --skip-publish --debug
@@ -301,7 +313,7 @@ release/publish:
301313
302314release-manifests : semver $(RELEASE_MANIFEST ) $(RELEASE_METADATA ) $(RELEASE_CLUSTER_TEMPLATE )
303315$(RELEASE_MANIFEST ) : $(RELEASE_DIR ) # # Builds the manifests to publish with a release
304- kustomize build config/default > $@
316+ $( KUSTOMIZE ) build config/default > $@
305317
306318$(RELEASE_METADATA ) : semver $(RELEASE_DIR ) $(METADATA_TEMPLATE )
307319 cat $(METADATA_TEMPLATE ) | sed ' s/MAJOR/$(VERSION_MAJOR)/g' | sed ' s/MINOR/$(VERSION_MINOR)/g' | sed ' s/CONTRACT/$(VERSION_CONTRACT)/g' > $@
@@ -321,7 +333,7 @@ $(FULL_RELEASE_CLUSTERCTLYAML): $(RELEASE_DIR)
321333managerless : semver managerless-manifests managerless-clusterctl managerless-cluster-template
322334managerless-manifests : semver $(MANAGERLESS_MANIFEST ) $(MANAGERLESS_METADATA )
323335$(MANAGERLESS_MANIFEST ) : $(MANAGERLESS_DIR )
324- kustomize build config/managerless > $@
336+ $( KUSTOMIZE ) build config/managerless > $@
325337
326338$(MANAGERLESS_METADATA ) : semver $(MANAGERLESS_DIR ) $(METADATA_TEMPLATE )
327339 cat $(METADATA_TEMPLATE ) | sed ' s/MAJOR/$(VERSION_MAJOR)/g' | sed ' s/MINOR/$(VERSION_MINOR)/g' | sed ' s/CONTRACT/$(VERSION_CONTRACT)/g' > $@
0 commit comments