Skip to content

Commit 3dd71d0

Browse files
Merge pull request #242 from linode/devbox
[feat] add support for devbox
2 parents 1b046af + 165f9d3 commit 3dd71d0

File tree

4 files changed

+792
-13
lines changed

4 files changed

+792
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ linode-cloud-controller-manager
99
# Folders
1010
_obj
1111
_test
12+
bin
1213

1314
# Architecture specific extensions/prefixes
1415
*.[568vq]

Makefile

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ IMG ?= linode/linode-cloud-controller-manager:canary
22
RELEASE_DIR ?= release
33
PLATFORM ?= 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+
521
export GO111MODULE=on
622

723
.PHONY: all
@@ -13,6 +29,7 @@ clean:
1329
@rm -rf ./.tmp
1430
@rm -rf dist/*
1531
@rm -rf $(RELEASE_DIR)
32+
@rm -rf $(LOCALBIN)
1633

1734
.PHONY: codegen
1835
codegen:
@@ -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
94112
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
95113
ifeq ($(filter darwin linux,$(HOSTOS)),)
96114
$(error build only supported on linux and darwin host currently)
97115
endif
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
99125
HELM_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

devbox.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"packages": [
3+
"ctlptl@latest",
4+
"clusterctl@latest",
5+
"docker@latest",
6+
"envsubst@latest",
7+
8+
"golangci-lint@latest",
9+
"jq@latest",
10+
"kind@latest",
11+
"kubectl@latest",
12+
"kustomize@latest",
13+
"kyverno-chainsaw@latest",
14+
"mockgen@latest",
15+
"yq-go@latest"
16+
],
17+
"shell": {
18+
"init_hook": [
19+
"export \"GOROOT=$(go env GOROOT)\""
20+
],
21+
"scripts": {}
22+
}
23+
}

0 commit comments

Comments
 (0)