Vendor k8s label selection, remove apimachinery fork - #562
Merged
Conversation
Add comprehensive tests for the pkg/selection public API: - TestParseLabelSelector: 21 subtests covering equality, inequality, set-based (in/notin), existence/non-existence, multiple requirements, and invalid selector syntax. - TestLabelSelectorMatches: 28 subtests covering matching behavior for all selector types against various label sets including nil, empty, matching, non-matching, and extra keys. - TestEnsureLabelKeyValid: 12 cases including qualified keys, boundary lengths, and invalid characters. - TestEnsureLabelValueValid: 10 cases including empty values, boundary lengths, and invalid formats. - TestExtractAndSortLabelKeys: 5 subtests for nil, empty, single, multiple, and special-character keys. Remove placeholder TODO comments from test files. Signed-off-by: Jacob Howard <jacob@mutagen.io>
xenoscopic
force-pushed
the
vendor-apimachinery
branch
from
April 22, 2026 10:35
dce3e98 to
0e3f6ae
Compare
Vendor the subset of k8s.io/apimachinery used for Kubernetes- style label selection into pkg/selection/internal/third_party/ apimachinery. This eliminates the mutagen-io/apimachinery fork (and its replace directive in go.mod), which existed solely to strip the klog dependency and its init-time goroutines from the Mutagen agent binary. Vendored from kubernetes/apimachinery at revision: kubernetes/apimachinery@f916759 (tag v0.21.3, via mutagen-io/apimachinery v0.21.3-mutagen1) Vendored packages: - pkg/labels: selector parsing and label matching - pkg/selection: operator enum - pkg/util/errors: aggregate error type - pkg/util/sets: string set (other set types omitted) - pkg/util/validation: name and label value validation - pkg/util/validation/field: error types and field paths Includes original k8s test files for labels, validation, and field packages. Each vendored file carries the full Apache 2.0 license header and extraction provenance. Two test cases in validation_test.go were adjusted for Go 1.17+ behavior (leading zeros in IPv4 octets now rejected). Removes 187 lines of transitive k8s dependency hashes from go.sum. Signed-off-by: Jacob Howard <jacob@mutagen.io>
xenoscopic
force-pushed
the
vendor-apimachinery
branch
from
April 22, 2026 10:39
0e3f6ae to
e778e78
Compare
Signed-off-by: Jacob Howard <jacob@mutagen.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Vendor the subset of
k8s.io/apimachineryused for Kubernetes-stylelabel selection into
pkg/selection/internal/third_party/apimachinery/,eliminating the
mutagen-io/apimachineryfork and itsreplacedirective in
go.mod.The fork existed solely to strip the
klogdependency, which bloatedagent binaries and spawned goroutines on
init(). By vendoring only thepackages Mutagen actually uses, we get the same benefit permanently
without maintaining a fork.
Originally extracted from
kubernetes/apimachineryatf916759cb6b8(tag v0.21.3), via
mutagen-io/apimachinery v0.21.3-mutagen1.Commit structure
test: expand label selection test coverage-- 56 new testsfor
pkg/selectionpublic API (parsing, matching, key/valuevalidation, key extraction). Runs against the fork to establish
baseline.
deps: vendor k8s label selection, remove apimachinery fork--Vendored code + original k8s test files. Same tests pass against
vendored code.
Vendored packages
labelsselectionutil/errorsutil/setsutil/validationutil/validation/fieldEach file carries the full Apache 2.0 license header and extraction
provenance, following the existing pattern in
pkg/filesystem/watching/internal/third_party/.What's removed
k8s.io/apimachineryrequire line fromgo.modreplace k8s.io/apimachinery => github.com/mutagen-io/apimachinerygo.sumTest plan
go test ./pkg/selection/...passes (56 Mutagen-level tests +vendored k8s tests for labels, validation, and field packages)
go build ./cmd/... ./pkg/...passesgo vet ./cmd/... ./pkg/...passes clean