Skip to content

Commit 78d3f54

Browse files
rgarciaclaude
andauthored
fix: pin oapi-codegen version via go.mod tool directive (#210)
## Summary - Adds `tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen` directive to `server/go.mod`, pinning oapi-codegen at v2.6.0 via go.sum - Switches `server/Makefile` from `go install ...@latest` to `go tool oapi-codegen` so the pinned version is always used - Removes the `OAPI_CODEGEN` binary variable and install target from the Makefile (no longer needed) This is the root cause fix for the version regression in #201 (where `@latest` resolved to v2.5.1 instead of v2.6.0). PR #209 already restored the generated code; this PR prevents it from happening again by adopting the same `go.mod` tool directive pattern used in `kernel/kernel`. ## Test plan - [x] `go vet ./...` passes - [x] Unit tests pass (`go test -race` on all non-e2e packages) - [x] `go tool oapi-codegen -config ./oapi-codegen.yaml ./openapi-3.0.yaml` uses pinned v2.6.0 - [ ] CI server-test workflow passes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk build tooling change: it only affects OpenAPI code generation and Go module dependency resolution, not runtime behavior. Main risk is unexpected dependency/tooling differences if the pinned tool or updated transitive deps behave differently across environments. > > **Overview** > **Pins `oapi-codegen` for reproducible OpenAPI generation.** `server/go.mod` now declares `oapi-codegen` as a Go `tool` dependency (and updates module sums), and `server/Makefile` switches `oapi-generate` from installing `@latest` into `bin/` to invoking `go tool oapi-codegen`. > > This removes the Makefile’s local `oapi-codegen` install target/variable and updates Go module dependencies (including bumping `github.com/getkin/kin-openapi` to `v0.133.0`) to reflect the pinned toolchain. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d7632bf. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 306ac35 commit 78d3f54

File tree

3 files changed

+135
-10
lines changed

3 files changed

+135
-10
lines changed

server/Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ SHELL := /bin/bash
22
.PHONY: oapi-generate build dev test clean
33

44
BIN_DIR ?= $(CURDIR)/bin
5-
OAPI_CODEGEN ?= $(BIN_DIR)/oapi-codegen
65
RECORDING_DIR ?= $(CURDIR)/recordings
76

87
$(BIN_DIR):
@@ -11,17 +10,14 @@ $(BIN_DIR):
1110
$(RECORDING_DIR):
1211
mkdir -p $(RECORDING_DIR)
1312

14-
$(OAPI_CODEGEN): | $(BIN_DIR)
15-
GOBIN=$(BIN_DIR) go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
16-
1713
# Generate Go code from the OpenAPI spec
1814
# 1. Convert 3.1 → 3.0 since oapi-codegen doesn't support 3.1 yet (https://github.com/oapi-codegen/oapi-codegen/issues/373)
19-
# 2. Run oapi-codegen with our config
15+
# 2. Run oapi-codegen with our config (version pinned via go.mod tool directive)
2016
# 3. go mod tidy to pull deps
21-
oapi-generate: $(OAPI_CODEGEN)
17+
oapi-generate:
2218
pnpm i -g @apiture/openapi-down-convert
2319
openapi-down-convert --input openapi.yaml --output openapi-3.0.yaml
24-
$(OAPI_CODEGEN) -config ./oapi-codegen.yaml ./openapi-3.0.yaml
20+
go tool oapi-codegen -config ./oapi-codegen.yaml ./openapi-3.0.yaml
2521
@echo "Fixing oapi-codegen issue https://github.com/oapi-codegen/oapi-codegen/issues/1764..."
2622
go run ./scripts/oapi/patch_sse_methods -file ./lib/oapi/oapi.go -expected-replacements 3
2723
go fmt ./lib/oapi/oapi.go

server/go.mod

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ module github.com/kernel/kernel-images/server
22

33
go 1.25.0
44

5+
tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
6+
57
require (
68
github.com/avast/retry-go/v5 v5.0.0
79
github.com/coder/websocket v1.8.14
810
github.com/creack/pty v1.1.24
911
github.com/docker/docker v28.5.1+incompatible
1012
github.com/docker/go-connections v0.6.0
1113
github.com/fsnotify/fsnotify v1.9.0
12-
github.com/getkin/kin-openapi v0.132.0
14+
github.com/getkin/kin-openapi v0.133.0
1315
github.com/ghodss/yaml v1.0.0
1416
github.com/glebarez/sqlite v1.11.0
1517
github.com/go-chi/chi/v5 v5.2.1
@@ -42,6 +44,7 @@ require (
4244
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
4345
github.com/distribution/reference v0.6.0 // indirect
4446
github.com/docker/go-units v0.5.0 // indirect
47+
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
4548
github.com/dustin/go-humanize v1.0.1 // indirect
4649
github.com/ebitengine/purego v0.8.4 // indirect
4750
github.com/felixge/httpsnoop v1.0.4 // indirect
@@ -67,6 +70,7 @@ require (
6770
github.com/moby/term v0.5.0 // indirect
6871
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
6972
github.com/morikuni/aec v1.0.0 // indirect
73+
github.com/oapi-codegen/oapi-codegen/v2 v2.6.0 // indirect
7074
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
7175
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
7276
github.com/opencontainers/go-digest v1.0.0 // indirect
@@ -78,8 +82,12 @@ require (
7882
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
7983
github.com/shirou/gopsutil/v4 v4.25.6 // indirect
8084
github.com/sirupsen/logrus v1.9.3 // indirect
85+
github.com/speakeasy-api/jsonpath v0.6.0 // indirect
86+
github.com/speakeasy-api/openapi-overlay v0.10.2 // indirect
8187
github.com/tklauser/go-sysconf v0.3.12 // indirect
8288
github.com/tklauser/numcpus v0.6.1 // indirect
89+
github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
90+
github.com/woodsbury/decimal128 v1.3.0 // indirect
8391
github.com/yusufpapurcu/wmi v1.2.4 // indirect
8492
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
8593
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
@@ -90,7 +98,9 @@ require (
9098
go.opentelemetry.io/otel/trace v1.39.0 // indirect
9199
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
92100
golang.org/x/crypto v0.43.0 // indirect
101+
golang.org/x/mod v0.28.0 // indirect
93102
golang.org/x/text v0.30.0 // indirect
103+
golang.org/x/tools v0.37.0 // indirect
94104
google.golang.org/protobuf v1.36.10 // indirect
95105
gopkg.in/yaml.v2 v2.4.0 // indirect
96106
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)