@@ -2,6 +2,22 @@ IMG ?= linode/linode-cloud-controller-manager:canary
22RELEASE_DIR ?= release
33PLATFORM ?= linux/amd64
44
5+ # Use CACHE_BIN for tools that cannot use devbox and LOCALBIN for tools that can use either method
6+ CACHE_BIN ?= $(CURDIR ) /bin
7+ LOCALBIN ?= $(CACHE_BIN )
8+
9+ DEVBOX_BIN ?= $(DEVBOX_PACKAGES_DIR ) /bin
10+
11+ # if the $DEVBOX_PACKAGES_DIR env variable exists that means we are within a devbox shell and can safely
12+ # use devbox's bin for our tools
13+ ifdef DEVBOX_PACKAGES_DIR
14+ LOCALBIN = $(DEVBOX_BIN)
15+ endif
16+
17+ export PATH := $(CACHE_BIN ) :$(PATH )
18+ $(LOCALBIN ) :
19+ mkdir -p $(LOCALBIN )
20+
521export GO111MODULE =on
622
723.PHONY : all
1329 @rm -rf ./.tmp
1430 @rm -rf dist/*
1531 @rm -rf $(RELEASE_DIR )
32+ @rm -rf $(LOCALBIN )
1633
1734.PHONY : codegen
1835codegen :
@@ -90,33 +107,38 @@ run-debug: build
90107 --stderrthreshold=INFO \
91108 --kubeconfig=${KUBECONFIG} \
92109 --linodego-debug
110+
93111# Set the host's OS. Only linux and darwin supported for now
94112HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
95113ifeq ($(filter darwin linux,$(HOSTOS ) ) ,)
96114$(error build only supported on linux and darwin host currently)
97115endif
116+ ARCH =$(shell uname -m)
117+ ARCH_SHORT =$(ARCH )
118+ ifeq ($(ARCH_SHORT ) ,x86_64)
119+ ARCH_SHORT := amd64
120+ else ifeq ($(ARCH_SHORT),aarch64)
121+ ARCH_SHORT := arm64
122+ endif
98123
124+ HELM ?= $(LOCALBIN ) /helm
99125HELM_VERSION ?= v3.9.1
100- TOOLS_HOST_DIR ?= .tmp/tools
101- HELM := $(TOOLS_HOST_DIR ) /helm-$(HELM_VERSION )
102-
103- .PHONY : $(HELM )
104- $(HELM ) :
105- @echo installing helm $(HELM_VERSION )
106- @mkdir -p $(TOOLS_HOST_DIR ) /tmp-helm
107- @curl -fsSL https://get.helm.sh/helm-$(HELM_VERSION ) -$(HOSTOS ) -amd64.tar.gz | tar -xz -C $(TOOLS_HOST_DIR ) /tmp-helm
108- @mv $(TOOLS_HOST_DIR ) /tmp-helm/$(HOSTOS ) -amd64/helm $(HELM )
109- @rm -fr $(TOOLS_HOST_DIR ) /tmp-helm
110- @echo installing helm $(HELM_VERSION )
126+
127+ .PHONY : helm
128+ helm : $(HELM ) # # Download helm locally if necessary
129+ $(HELM ) : $(LOCALBIN )
130+ @curl -fsSL https://get.helm.sh/helm-$(HELM_VERSION ) -$(HOSTOS ) -$(ARCH_SHORT ) .tar.gz | tar -xz
131+ @mv $(HOSTOS ) -$(ARCH_SHORT ) /helm $(HELM )
132+ @rm -rf helm.tgz $(HOSTOS ) -$(ARCH_SHORT )
111133
112134.PHONY : helm-lint
113- helm-lint : $( HELM )
135+ helm-lint : helm
114136# Verify lint works when region and apiToken are passed, and when it is passed as reference.
115137 @$(HELM) lint deploy/chart --set apiToken="apiToken",region="us-east"
116138 @$(HELM) lint deploy/chart --set secretRef.apiTokenRef="apiToken",secretRef.name="api",secretRef.regionRef="us-east"
117139
118140.PHONY : helm-template
119- helm-template : $( HELM )
141+ helm-template : helm
120142# Verify template works when region and apiToken are passed, and when it is passed as reference.
121143 @$(HELM) template foo deploy/chart --set apiToken="apiToken",region="us-east" > /dev/null
122144 @$(HELM) template foo deploy/chart --set secretRef.apiTokenRef="apiToken",secretRef.name="api",secretRef.regionRef="us-east" > /dev/null
0 commit comments