Skip to content

Add go.mod - #1326

Merged
kolyshkin merged 2 commits into
opencontainers:mainfrom
kolyshkin:go-mod
Oct 13, 2026
Merged

kolyshkin merged 2 commits into
opencontainers:mainfrom
kolyshkin:go-mod

Conversation

@kolyshkin

@kolyshkin kolyshkin commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Since there is no go.mod, CI creates one on the fly using go mod init and go get. In addition, make docs doesn't work with Go 1.23+ (#1280), and the schema validator can't be built with Go 1.22+ (go get is no longer supported outside a module).

This PR:

  1. Moves the schema validator to its own module (schema/validate), so that its dependency (gojsonschema) does not become a dependency of github.com/opencontainers/runtime-spec.
  2. Adds go.mod with no dependencies, and the go directive set to the minimal Go version we support and test with (1.21), and removes go.mod creation from CI.
  3. Bumps golangci-lint to v2.14 (same as ci: bump golangci-lint to v2.14 #1325), since v2.10 (built with go1.26) can't work with Go 1.27, which is now the stable version.

(if #1325 is merged first, it's trivial to rebase this one)

For users of specs-go, nothing changes: the module path stays the same, and there are no new dependencies.

Fixes #1280.

Previously: #1068 was closed in favor of #1069 (making specs-go a separate module with its own tags), which has not happened since 2020. As noted in #1069 (comment), the Go code here is just struct definitions and constants, so separate Go releases are unlikely to be needed; image-spec also has go.mod at the top level.

@tianon tianon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anyone use "validate" enough to make this worthwhile to maintain?

Comment thread schema/validate/go.mod

go 1.21

require github.com/xeipuuv/gojsonschema v1.2.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should look if we can rewrite this to github.com/santhosh-tekuri/jsonschema/v6. This module is no longer maintained (I can have a look if it's an easy rewrite)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah

Copy link
Copy Markdown
Member

Does anyone use "validate" enough to make this worthwhile to maintain?

Good question as well; at least it's good to give it its own go.mod so that its dependencies don't become dependencies of the spec itself.

@giuseppe giuseppe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marquiz marquiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM

@thaJeztah

Copy link
Copy Markdown
Member

As noted in #1069 (comment), the Go code here is just struct definitions and constants, so separate Go releases are unlikely to be needed; image-spec also has go.mod at the top level.

Yeah, it was for things like 869b2d5 (#1279), which was a breaking change at least from the Go API side (and definitely caused some breakage down the line), so would've warranted a V2. It's the tricky bit of trying to version two distinct API stabilities (Go API vs spec API) into a single tag.

Given that the spec version is already captured in code, technically we could have them separate

const (
// VersionMajor is for an API incompatible changes
VersionMajor = 1
// VersionMinor is for functionality in a backwards-compatible manner
VersionMinor = 3
// VersionPatch is for backwards-compatible bug fixes
VersionPatch = 0
// VersionDev indicates development branch. Releases will be empty string.
VersionDev = "+dev"
)

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on having a go.mod; the "module version must match specs version" is still something to slightly consider though.

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to v1.3.1 milestone, but maybe we should skip it and bump the version to v1.4

@sudo-bmitch

Copy link
Copy Markdown
Contributor

Image-spec had a similar update a while back. It may make sense to move the validate code to a common location. If there's interest in doing that, we could open an issue with the TOB to setup a new repo and maintainers.

opencontainers/image-spec#1253

@thaJeztah

Copy link
Copy Markdown
Member

overall, I think a "sub" module in this repo is OK; I think it's used in CI to verify the json-schemas are done correctly, and it's .. very little code; bit on the fence on moving to a separate repo, as the amount of boiler-plating / maintenance to keep that up may be more than the little amount of code in it (at a quick glance).

The old way of building the validator (go get $DEPS && go build) no
longer works since Go 1.22:

	go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.

Move the validator sources into their own directory, with own go.mod.
This fixes the build, makes it possible to use go install, and, since
it is a separate module, its dependencies (gojsonschema) won't end up
as dependencies of github.com/opencontainers/runtime-spec once it gets
its own go.mod.

Fix build and test commands in README and Makefile accordingly (and
there's no need to run go get any more).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Since there is no go.mod, CI has to create one on the fly (using
"go mod init" and "go get"). In addition, "make docs" no longer works
with Go 1.23+, since "go run ./.tool/version-doc.go" requires a module.

Add go.mod (with no dependencies, and the go directive set to the
minimal Go version we support and test with), and remove the go.mod
creation from CI.

Since schema/validate is now a separate module, run golangci-lint
for it separately. To avoid using golangci-lint-action twice, bump it
to v9 and use its install-only mode, running golangci-lint directly.

Fixes opencontainers#1280.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
kolyshkin merged commit bb96cde into opencontainers:main Oct 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc builds fail with Go 1.23

7 participants