Skip to content

Commit 377c243

Browse files
committed
bump go to 1.25, move tools into go tools where possible
1 parent 4a975d9 commit 377c243

File tree

7 files changed

+1336
-510
lines changed

7 files changed

+1336
-510
lines changed

Makefile

Lines changed: 84 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ CACHE_BIN ?= $(CURDIR)/bin
77
LOCALBIN ?= $(CACHE_BIN)
88

99
DEVBOX_BIN ?= $(DEVBOX_PACKAGES_DIR)/bin
10-
HELM ?= $(LOCALBIN)/helm
11-
HELM_VERSION ?= v3.16.3
1210

1311
#####################################################################
1412
# Dev Setup
@@ -31,7 +29,6 @@ LINODE_URL ?= https://api.linode.com
3129
KUBECONFIG_PATH ?= $(CURDIR)/test-cluster-kubeconfig.yaml
3230
SUBNET_KUBECONFIG_PATH ?= $(CURDIR)/subnet-testing-kubeconfig.yaml
3331
MGMT_KUBECONFIG_PATH ?= $(CURDIR)/mgmt-cluster-kubeconfig.yaml
34-
GOLANGCI_LINT_VERSION ?= v2.1.5
3532

3633
# if the $DEVBOX_PACKAGES_DIR env variable exists that means we are within a devbox shell and can safely
3734
# use devbox's bin for our tools
@@ -48,6 +45,12 @@ export GO111MODULE=on
4845
.PHONY: all
4946
all: build
5047

48+
## --------------------------------------
49+
## Cleanup
50+
## --------------------------------------
51+
52+
##@ Cleanup:
53+
5154
.PHONY: clean
5255
clean:
5356
@go clean .
@@ -56,32 +59,55 @@ clean:
5659
@rm -rf $(RELEASE_DIR)
5760
@rm -rf $(LOCALBIN)
5861

59-
.PHONY: codegen
60-
codegen:
61-
go generate ./...
62+
## --------------------------------------
63+
## Development
64+
## --------------------------------------
65+
66+
##@ Development:
67+
68+
.PHONY: fmt
69+
fmt: ## Run go fmt against code.
70+
go fmt ./...
6271

6372
.PHONY: vet
64-
vet: fmt
73+
vet: ## Run go vet against code.
6574
go vet ./...
6675

76+
.PHONY: gosec
77+
gosec: tools ## Run gosec against code.
78+
gosec -exclude-dir=bin -exclude-generated ./...
79+
6780
.PHONY: lint
68-
lint:
69-
docker run --rm -w /workdir -v $(PWD):/workdir golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) golangci-lint run -c .golangci.yml --fix
81+
lint: tools ## Run lint against code.
82+
golangci-lint run -c .golangci.yml
7083

71-
.PHONY: gosec
72-
gosec: ## Run gosec against code.
73-
docker run --rm -v "$(PWD):/var/work:ro" -w /var/work securego/gosec:2.19.0 \
74-
-exclude-dir=bin -exclude-generated ./...
84+
.PHONY: nilcheck
85+
nilcheck: tools ## Run nil check against code.
86+
go list ./... | xargs -I {} -d '\n' nilaway -include-pkgs {} -exclude-file-docstrings "ignore_autogenerated" ./...
7587

76-
.PHONY: fmt
77-
fmt:
78-
go fmt ./...
88+
.PHONY: vulncheck
89+
vulncheck: tools ## Run vulnerability check against code.
90+
govulncheck ./...
91+
92+
.PHONY: codegen
93+
codegen:
94+
go generate ./...
95+
96+
## --------------------------------------
97+
## Testing
98+
## --------------------------------------
99+
100+
##@ Testing:
79101

80102
.PHONY: test
81103
# we say code is not worth testing unless it's formatted
82104
test: fmt codegen
83105
go test -v -coverpkg=./sentry,./cloud/linode/client,./cloud/linode,./cloud/linode/utils,./cloud/linode/services,./cloud/nodeipam,./cloud/nodeipam/ipam -coverprofile ./coverage.out -cover ./sentry/... ./cloud/... $(TEST_ARGS)
84106

107+
## --------------------------------------
108+
## Build
109+
## --------------------------------------
110+
85111
.PHONY: build-linux
86112
build-linux: codegen
87113
echo "cross compiling linode-cloud-controller-manager for linux/amd64" && \
@@ -142,21 +168,21 @@ run-debug: build
142168
#####################################################################
143169

144170
.PHONY: mgmt-and-capl-cluster
145-
mgmt-and-capl-cluster: docker-setup mgmt-cluster capl-cluster
171+
mgmt-and-capl-cluster: tools docker-setup mgmt-cluster capl-cluster
146172

147173
.PHONY: capl-cluster
148-
capl-cluster: generate-capl-cluster-manifests create-capl-cluster patch-linode-ccm
174+
capl-cluster: tools generate-capl-cluster-manifests create-capl-cluster patch-linode-ccm
149175

150176
.PHONY: generate-capl-cluster-manifests
151-
generate-capl-cluster-manifests:
177+
generate-capl-cluster-manifests: tools
152178
# Create the CAPL cluster manifests without any CSI driver stuff
153179
LINODE_FIREWALL_ENABLED=$(LINODE_FIREWALL_ENABLED) LINODE_OS=$(LINODE_OS) VPC_NAME=$(VPC_NAME) clusterctl generate cluster $(CLUSTER_NAME) \
154180
--kubernetes-version $(K8S_VERSION) --infrastructure linode-linode:$(CAPL_VERSION) \
155181
--control-plane-machine-count $(CONTROLPLANE_NODES) --worker-machine-count $(WORKER_NODES) > $(MANIFEST_NAME).yaml
156182
yq -i e 'select(.kind == "LinodeVPC").spec.subnets = [{"ipv4": "10.0.0.0/8", "label": "default"}, {"ipv4": "172.16.0.0/16", "label": "testing"}]' $(MANIFEST_NAME).yaml
157183

158184
.PHONY: create-capl-cluster
159-
create-capl-cluster:
185+
create-capl-cluster: tools
160186
# Create a CAPL cluster with updated CCM and wait for it to be ready
161187
kubectl apply -f $(MANIFEST_NAME).yaml
162188
kubectl wait --for=condition=ControlPlaneReady cluster/$(CLUSTER_NAME) --timeout=600s || (kubectl get cluster -o yaml; kubectl get linodecluster -o yaml; kubectl get linodemachines -o yaml)
@@ -167,14 +193,14 @@ create-capl-cluster:
167193
KUBECONFIG=$(KUBECONFIG_PATH) kubectl taint nodes -l node-role.kubernetes.io/control-plane node-role.kubernetes.io/control-plane-
168194

169195
.PHONY: patch-linode-ccm
170-
patch-linode-ccm:
196+
patch-linode-ccm: tools
171197
KUBECONFIG=$(KUBECONFIG_PATH) kubectl patch -n kube-system daemonset ccm-linode --type='json' -p="[{'op': 'replace', 'path': '/spec/template/spec/containers/0/image', 'value': '${IMG}'}]"
172198
KUBECONFIG=$(KUBECONFIG_PATH) kubectl patch -n kube-system daemonset ccm-linode --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/env/-", "value": {"name": "LINODE_API_VERSION", "value": "v4beta"}}]'
173199
KUBECONFIG=$(KUBECONFIG_PATH) kubectl rollout status -n kube-system daemonset/ccm-linode --timeout=600s
174200
KUBECONFIG=$(KUBECONFIG_PATH) kubectl -n kube-system get daemonset/ccm-linode -o yaml
175201

176202
.PHONY: mgmt-cluster
177-
mgmt-cluster:
203+
mgmt-cluster: tools
178204
# Create a mgmt cluster
179205
ctlptl apply -f e2e/setup/ctlptl-config.yaml
180206
clusterctl init \
@@ -188,14 +214,14 @@ mgmt-cluster:
188214
kind get kubeconfig --name=caplccm > $(MGMT_KUBECONFIG_PATH)
189215

190216
.PHONY: cleanup-cluster
191-
cleanup-cluster:
217+
cleanup-cluster: tools
192218
kubectl delete cluster -A --all --timeout=180s
193219
kubectl delete linodefirewalls -A --all --timeout=60s
194220
kubectl delete lvpc -A --all --timeout=60s
195221
kind delete cluster -n caplccm
196222

197223
.PHONY: e2e-test
198-
e2e-test:
224+
e2e-test: tools
199225
CLUSTER_NAME=$(CLUSTER_NAME) \
200226
MGMT_KUBECONFIG=$(MGMT_KUBECONFIG_PATH) \
201227
KUBECONFIG=$(KUBECONFIG_PATH) \
@@ -205,7 +231,7 @@ e2e-test:
205231
chainsaw test e2e/test --parallel 2 $(E2E_FLAGS)
206232

207233
.PHONY: e2e-test-bgp
208-
e2e-test-bgp:
234+
e2e-test-bgp: tools
209235
KUBECONFIG=$(KUBECONFIG_PATH) CLUSTER_SUFFIX=$(CLUSTER_NAME) ./e2e/setup/cilium-setup.sh
210236
KUBECONFIG=$(KUBECONFIG_PATH) kubectl -n kube-system rollout status daemonset/ccm-linode --timeout=300s
211237
CLUSTER_NAME=$(CLUSTER_NAME) \
@@ -217,7 +243,7 @@ e2e-test-bgp:
217243
chainsaw test e2e/bgp-test/lb-cilium-bgp $(E2E_FLAGS)
218244

219245
.PHONY: e2e-test-subnet
220-
e2e-test-subnet:
246+
e2e-test-subnet: tools
221247
# Generate cluster manifests for second cluster
222248
SUBNET_NAME=testing CLUSTER_NAME=$(SUBNET_CLUSTER_NAME) MANIFEST_NAME=$(SUBNET_MANIFEST_NAME) VPC_NAME=$(CLUSTER_NAME) \
223249
VPC_NETWORK_CIDR=172.16.0.0/16 K8S_CLUSTER_CIDR=172.16.64.0/18 make generate-capl-cluster-manifests
@@ -255,6 +281,25 @@ else ifeq ($(ARCH_SHORT),aarch64)
255281
ARCH_SHORT := arm64
256282
endif
257283

284+
## --------------------------------------
285+
## Tooling Binaries
286+
## --------------------------------------
287+
288+
##@ Tooling Binaries:
289+
HELM ?= $(LOCALBIN)/helm
290+
291+
## Tool Versions
292+
CLUSTERCTL_VERSION ?= v1.11.1
293+
KUBECTL_VERSION ?= v1.28.0
294+
CHAINSAW_VERSION ?= v0.2.13
295+
HELM_VERSION ?= v3.16.3
296+
297+
.PHONY: tools
298+
tools: $(CLUSTERCTL) $(KUBECTL)
299+
go install tool
300+
##@ we can't manage this with go tools because it causes a panic due to missing CRDs when running chainsaw
301+
go install github.com/kyverno/chainsaw@$(CHAINSAW_VERSION)
302+
258303
.PHONY: helm
259304
helm: $(HELM) ## Download helm locally if necessary
260305
$(HELM): $(LOCALBIN)
@@ -273,3 +318,16 @@ helm-template: helm
273318
#Verify template works when region and apiToken are passed, and when it is passed as reference.
274319
@$(HELM) template foo deploy/chart --set apiToken="apiToken",region="us-east" > /dev/null
275320
@$(HELM) template foo deploy/chart --set secretRef.apiTokenRef="apiToken",secretRef.name="api",secretRef.regionRef="us-east" > /dev/null
321+
322+
.PHONY: kubectl
323+
kubectl: $(KUBECTL) ## Download kubectl locally if necessary.
324+
$(KUBECTL): $(LOCALBIN)
325+
curl -fsSL https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/$(OS)/$(ARCH_SHORT)/kubectl -o $(KUBECTL)
326+
chmod +x $(KUBECTL)
327+
328+
329+
.PHONY: clusterctl
330+
clusterctl: $(CLUSTERCTL) ## Download clusterctl locally if necessary.
331+
$(CLUSTERCTL): $(LOCALBIN)
332+
curl -fsSL https://github.com/kubernetes-sigs/cluster-api/releases/download/$(CLUSTERCTL_VERSION)/clusterctl-$(OS)-$(ARCH_SHORT) -o $(CLUSTERCTL)
333+
chmod +x $(CLUSTERCTL)

cloud/annotations/annotations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616
AnnLinodeHealthCheckInterval = "service.beta.kubernetes.io/linode-loadbalancer-check-interval"
1717
AnnLinodeHealthCheckTimeout = "service.beta.kubernetes.io/linode-loadbalancer-check-timeout"
1818
AnnLinodeHealthCheckAttempts = "service.beta.kubernetes.io/linode-loadbalancer-check-attempts"
19+
//gosec:disable G101 -- This is a false positive
1920
AnnLinodeHealthCheckPassive = "service.beta.kubernetes.io/linode-loadbalancer-check-passive"
2021

2122
AnnLinodeUDPCheckPort = "service.beta.kubernetes.io/linode-loadbalancer-udp-check-port"

cloud/linode/cloud.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
const (
2323
// The name of this cloudprovider
2424
ProviderName = "linode"
25+
//gosec:disable G101 -- This is a false positive
2526
accessTokenEnv = "LINODE_API_TOKEN"
2627
regionEnv = "LINODE_REGION"
2728
ciliumLBType = "cilium-bgp"

devbox.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
{
22
"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"
3+
4+
5+
6+
7+
8+
9+
1610
],
1711
"shell": {
1812
"init_hook": [

0 commit comments

Comments
 (0)