Skip to content

Switch from gopkg.in/yaml.v3 to go.yaml.in/yaml/v3 - #497

Merged
peppescg merged 1 commit into
mainfrom
chore/go-yaml-in-yaml-v3
Nov 10, 2026
Merged

peppescg merged 1 commit into
mainfrom
chore/go-yaml-in-yaml-v3

Conversation

@peppescg

Copy link
Copy Markdown
Contributor

Fixes #493

Summary

  • Replace every gopkg.in/yaml.v3 import (3 packages, 4 test files) with go.yaml.in/yaml/v3, the maintained continuation of the archived go-yaml project, with the same v3 API.
  • go.yaml.in/yaml/v3 becomes a direct requirement; go mod tidy drops gopkg.in/yaml.v3 from go.mod (it stays in the module graph only through a sigstore/rekor test dependency).
  • Add a depguard rule (archived_yaml, test files included) that rejects gopkg.in/yaml.v3, since it is still in the module graph and editors can auto-import it.

Note for consumers: registry.ImageMetadata and registry.RemoteServerMetadata implement UnmarshalYAML(*yaml.Node) to flatten the embedded BaseServerMetadata fields. The node type is now go.yaml.in/yaml/v3's, so these custom unmarshalers run when the caller decodes with go.yaml.in/yaml/v3 and not with gopkg.in/yaml.v3 (until now it was the reverse). A code search over the stacklok org finds no production code decoding these types from YAML; toolhive main already requires go.yaml.in/yaml/v3 directly.

Benefit (measured)

Two throwaway consumer modules built against main and against this branch (replace to each checkout, go mod tidy, go run):

Check main this branch
go.mod of a consumer that only uses config.Decode require gopkg.in/yaml.v3 v3.0.1 // indirect require go.yaml.in/yaml/v3 v3.0.6 // indirect
config.Decode of a valid document decoded decoded (same result)
config.Decode with an unknown key prot line 3: field prot not found in type main.appConfig same error
ImageMetadata decoded with go.yaml.in/yaml/v3 name="", description="", tier="" (base fields lost) name="fetch", description="Fetches URLs", tier="Official"

Test plan

  • No .go file imports gopkg.in/yaml.v3 (grep -rn '"gopkg.in/yaml.v3"' --include='*.go' . is empty).
  • Existing tests unchanged apart from the import line. Switching only the test imports while the production code stayed on gopkg.in/yaml.v3 fails 6 registry/types tests (the YAML round-trips lose the base fields), so these tests pin the switch.
  • The depguard rule fires on a test file that imports gopkg.in/yaml.v3; in non-test code the build already fails because go.mod no longer requires it.
  • task lint, task license-check, task redisconn-modules (nested modules unchanged).
  • go test -race ./... green apart from networking TestValidateCallbackPort, which needs port 8090 free and was held by another process on the machine that ran it.

🤖 Generated with Claude Code

gopkg.in/yaml.v3 is archived and unmaintained; go.yaml.in/yaml/v3 is
its maintained continuation under the YAML organization, with the same
v3 API. Replace every import, make go.yaml.in/yaml/v3 a direct
requirement (go mod tidy drops gopkg.in/yaml.v3 from go.mod), and add a
depguard rule, test files included, so the old path is not
auto-imported back.

registry.ImageMetadata and registry.RemoteServerMetadata now implement
UnmarshalYAML with go.yaml.in/yaml/v3's Node, so their custom
unmarshaling runs for callers that decode with go.yaml.in/yaml/v3.

Fixes #493

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@peppescg peppescg self-assigned this Nov 10, 2026
@peppescg
peppescg merged commit 673889f into main Nov 10, 2026
6 checks passed
@peppescg
peppescg deleted the chore/go-yaml-in-yaml-v3 branch November 10, 2026 18:16
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.

Switch from gopkg.in/yaml.v3 to go.yaml.in/yaml/v3

2 participants