Skip to content

Commit a3972f9

Browse files
committed
chore: Bump to go-1.24, use go tools
1 parent dab65d7 commit a3972f9

File tree

11 files changed

+886
-1801
lines changed

11 files changed

+886
-1801
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ updates:
88
- "k8s.io*"
99
schedule:
1010
interval: "weekly"
11-
- package-ecosystem: "gomod"
12-
directory: "tools"
13-
schedule:
14-
interval: "weekly"
1511
- package-ecosystem: "github-actions"
1612
directory: "/"
1713
schedule:

.github/workflows/ci.yml

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ env:
2020
E2E_SETUP_KIND: yes
2121
E2E_SETUP_KUBECTL: yes
2222
SUDO: sudo
23-
GO_VERSION: "^1.23"
24-
GOLANGCI_LINT_VERSION: "v1.61.0"
23+
GO_VERSION: "^1.24"
24+
GOLANGCI_LINT_VERSION: "v1.64.6"
2525

2626
jobs:
2727
ci-go-lint:
@@ -37,10 +37,6 @@ jobs:
3737
go-version: ${{ env.GO_VERSION }}
3838
id: go
3939

40-
- name: Setup environment
41-
run: |
42-
make install-tools
43-
4440
- name: Lint
4541
run: |
4642
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${{ env.GOLANGCI_LINT_VERSION }}
@@ -59,10 +55,6 @@ jobs:
5955
go-version: ${{ env.GO_VERSION }}
6056
id: go
6157

62-
- name: Setup environment
63-
run: |
64-
make install-tools
65-
6658
- name: Validate generated manifests
6759
run: |
6860
make validate-manifests
@@ -80,10 +72,6 @@ jobs:
8072
go-version: ${{ env.GO_VERSION }}
8173
id: go
8274

83-
- name: Setup environment
84-
run: |
85-
make install-tools
86-
8775
- name: Validate go modules
8876
run: |
8977
make validate-modules
@@ -101,10 +89,6 @@ jobs:
10189
go-version: ${{ env.GO_VERSION }}
10290
id: go
10391

104-
- name: Setup environment
105-
run: |
106-
make install-tools
107-
10892
- name: Check that all metrics are documented and templates have no delta
10993
run: |
11094
make doccheck
@@ -122,10 +106,6 @@ jobs:
122106
go-version: ${{ env.GO_VERSION }}
123107
id: go
124108

125-
- name: Setup environment
126-
run: |
127-
make install-tools
128-
129109
- name: Unit tests
130110
run: |
131111
make test-unit
@@ -158,10 +138,6 @@ jobs:
158138
go-version: ${{ env.GO_VERSION }}
159139
id: go
160140

161-
- name: Setup environment
162-
run: |
163-
make install-tools
164-
165141
- name: Benchmark tests
166142
run: |
167143
BENCHSTAT_OUTPUT_FILE=result.txt make test-benchmark-compare
@@ -189,10 +165,6 @@ jobs:
189165
go-version: ${{ env.GO_VERSION }}
190166
id: go
191167

192-
- name: Setup environment
193-
run: |
194-
make install-tools
195-
196168
- name: Build
197169
run: |
198170
make build
@@ -210,10 +182,6 @@ jobs:
210182
go-version: ${{ env.GO_VERSION }}
211183
id: go
212184

213-
- name: Setup environment
214-
run: |
215-
make install-tools
216-
217185
- name: End-to-end tests
218186
run: |
219187
make e2e

.github/workflows/govulncheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- cron: '0 0 * * 1'
77

88
env:
9-
GO_VERSION: "^1.23"
9+
GO_VERSION: "^1.24"
1010

1111
permissions:
1212
contents: read

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
ARG GOVERSION=1.23
1+
ARG GOVERSION=1.24
22
ARG GOARCH
33
FROM golang:${GOVERSION} AS builder
44
ARG GOARCH
55
ENV GOARCH=${GOARCH}
66
WORKDIR /go/src/k8s.io/kube-state-metrics/
77
COPY . /go/src/k8s.io/kube-state-metrics/
88

9-
RUN make install-tools && make build-local
9+
RUN make build-local
1010

1111
FROM gcr.io/distroless/static-debian12:latest-${GOARCH}
1212
COPY --from=builder /go/src/k8s.io/kube-state-metrics/kube-state-metrics /

Makefile

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ VERSION = $(shell grep '^version:' data.yaml | grep -oE "[0-9]+.[0-9]+.[0-9]+")
66
TAG ?= $(TAG_PREFIX)$(VERSION)
77
LATEST_RELEASE_BRANCH := release-$(shell echo $(VERSION) | grep -ohE "[0-9]+.[0-9]+")
88
BRANCH = $(strip $(shell git rev-parse --abbrev-ref HEAD))
9-
DOCKER_CLI ?= docker
10-
PROMTOOL_CLI ?= promtool
119
PKGS = $(shell go list ./... | grep -v /vendor/ | grep -v /tests/e2e)
1210
ARCH ?= $(shell go env GOARCH)
1311
BUILD_DATE = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
@@ -16,13 +14,20 @@ OS ?= $(shell uname -s | tr A-Z a-z)
1614
ALL_ARCH = amd64 arm arm64 ppc64le s390x
1715
PKG = github.com/prometheus/common
1816
PROMETHEUS_VERSION = 2.55.1
19-
GO_VERSION = 1.23.5
17+
GO_VERSION = 1.24.1
2018
IMAGE = $(REGISTRY)/kube-state-metrics
2119
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
2220
USER ?= $(shell id -u -n)
2321
HOST ?= $(shell hostname)
2422
MARKDOWNLINT_CLI2_VERSION = 0.17.2
2523

24+
DOCKER_CLI ?= docker
25+
PROMTOOL_CLI ?= promtool
26+
GOMPLATE_CLI ?= go tool github.com/hairyhenderson/gomplate/v4/cmd/gomplate
27+
GOJSONTOYAML_CLI ?= go tool github.com/brancz/gojsontoyaml
28+
EMBEDMD_CLI ?= go tool github.com/campoy/embedmd
29+
JSONNET_CLI ?= go tool github.com/google/go-jsonnet/cmd/jsonnet
30+
JB_CLI ?= go tool github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
2631

2732
export DOCKER_CLI_EXPERIMENTAL=enabled
2833

@@ -88,7 +93,7 @@ fix-markdown-format:
8893
${DOCKER_CLI} run -v "${PWD}:/workdir" davidanson/markdownlint-cli2:v${MARKDOWNLINT_CLI2_VERSION} --fix --config .markdownlint-cli2.jsonc
8994

9095
generate-template:
91-
gomplate -d config=./data.yaml --file README.md.tpl > README.md
96+
${GOMPLATE_CLI} -d config=./data.yaml --file README.md.tpl > README.md
9297

9398
validate-template: generate-template
9499
git diff --no-ext-diff --quiet --exit-code README.md
@@ -138,7 +143,7 @@ e2e:
138143
generate: build-local generate-template
139144
@echo ">> generating docs"
140145
@./scripts/generate-help-text.sh
141-
embedmd -w `find . -path ./vendor -prune -o -name "*.md" -print`
146+
${EMBEDMD_CLI} -w `find . -path ./vendor -prune -o -name "*.md" -print`
142147

143148
validate-manifests: examples
144149
@git diff --exit-code
@@ -147,31 +152,27 @@ mixin: examples/prometheus-alerting-rules/alerts.yaml
147152

148153
examples/prometheus-alerting-rules/alerts.yaml: jsonnet $(shell find jsonnet | grep ".libsonnet") scripts/mixin.jsonnet scripts/vendor
149154
mkdir -p examples/prometheus-alerting-rules
150-
jsonnet -J scripts/vendor scripts/mixin.jsonnet | gojsontoyaml > examples/prometheus-alerting-rules/alerts.yaml
155+
${JSONNET_CLI} -J scripts/vendor scripts/mixin.jsonnet | ${GOJSONTOYAML_CLI} > examples/prometheus-alerting-rules/alerts.yaml
151156

152157
examples: examples/standard examples/autosharding examples/daemonsetsharding mixin
153158

154159
examples/standard: jsonnet $(shell find jsonnet | grep ".libsonnet") scripts/standard.jsonnet scripts/vendor
155160
mkdir -p examples/standard
156-
jsonnet -J scripts/vendor -m examples/standard --ext-str version="$(VERSION)" scripts/standard.jsonnet | xargs -I{} sh -c 'cat {} | gojsontoyaml > `echo {} | sed "s/\(.\)\([A-Z]\)/\1-\2/g" | tr "[:upper:]" "[:lower:]"`.yaml' -- {}
161+
${JSONNET_CLI}} -J scripts/vendor -m examples/standard --ext-str version="$(VERSION)" scripts/standard.jsonnet | xargs -I{} sh -c 'cat {} | ${GOJSONTOYAML_CLI} > `echo {} | sed "s/\(.\)\([A-Z]\)/\1-\2/g" | tr "[:upper:]" "[:lower:]"`.yaml' -- {}
157162
find examples -type f ! -name '*.yaml' -delete
158163

159164
examples/autosharding: jsonnet $(shell find jsonnet | grep ".libsonnet") scripts/autosharding.jsonnet scripts/vendor
160165
mkdir -p examples/autosharding
161-
jsonnet -J scripts/vendor -m examples/autosharding --ext-str version="$(VERSION)" scripts/autosharding.jsonnet | xargs -I{} sh -c 'cat {} | gojsontoyaml > `echo {} | sed "s/\(.\)\([A-Z]\)/\1-\2/g" | tr "[:upper:]" "[:lower:]"`.yaml' -- {}
166+
${JSONNET_CLI} -J scripts/vendor -m examples/autosharding --ext-str version="$(VERSION)" scripts/autosharding.jsonnet | xargs -I{} sh -c 'cat {} | ${GOJSONTOYAML_CLI} > `echo {} | sed "s/\(.\)\([A-Z]\)/\1-\2/g" | tr "[:upper:]" "[:lower:]"`.yaml' -- {}
162167
find examples -type f ! -name '*.yaml' -delete
163168

164169
examples/daemonsetsharding: jsonnet $(shell find jsonnet | grep ".libsonnet") scripts/daemonsetsharding.jsonnet scripts/vendor
165170
mkdir -p examples/daemonsetsharding
166-
jsonnet -J scripts/vendor -m examples/daemonsetsharding --ext-str version="$(VERSION)" scripts/daemonsetsharding.jsonnet | xargs -I{} sh -c 'cat {} | gojsontoyaml > `echo {} | sed "s/\(.\)\([A-Z]\)/\1-\2/g" | tr "[:upper:]" "[:lower:]"`.yaml' -- {}
171+
${JSONETT_CLI} -J scripts/vendor -m examples/daemonsetsharding --ext-str version="$(VERSION)" scripts/daemonsetsharding.jsonnet | xargs -I{} sh -c 'cat {} | ${GOJSONTOYAML_CLI} > `echo {} | sed "s/\(.\)\([A-Z]\)/\1-\2/g" | tr "[:upper:]" "[:lower:]"`.yaml' -- {}
167172
find examples -type f ! -name '*.yaml' -delete
168173

169174
scripts/vendor: scripts/jsonnetfile.json scripts/jsonnetfile.lock.json
170-
cd scripts && jb install
171-
172-
install-tools:
173-
@echo Installing tools from tools.go
174-
grep '^\s*_' tools/tools.go | awk '{print $$2}' | xargs -tI % go install -mod=readonly -modfile=tools/go.mod %
175+
cd scripts && ${JB_CLI} install
175176

176177
install-promtool:
177178
@echo Installing promtool

0 commit comments

Comments
 (0)