Skip to content

Commit 95c76a7

Browse files
committed
envtest: replace github.com/blang/semver with k8s.io/apimachinery
The former is no longer maintained and the latter is designed to understand Kubernetes versions. This eliminates one direct dependency introduced in b04d5fd. Signed-off-by: Chris Bandy <[email protected]>
1 parent 6824653 commit 95c76a7

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

examples/scratch-env/go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ require (
1010

1111
require (
1212
github.com/beorn7/perks v1.0.1 // indirect
13-
github.com/blang/semver/v4 v4.0.0 // indirect
1413
github.com/cespare/xxhash/v2 v2.3.0 // indirect
1514
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1615
github.com/emicklei/go-restful/v3 v3.12.2 // indirect

examples/scratch-env/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
22
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
3-
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
4-
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
53
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
64
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
75
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module sigs.k8s.io/controller-runtime
33
go 1.24.0
44

55
require (
6-
github.com/blang/semver/v4 v4.0.0
76
github.com/evanphx/json-patch/v5 v5.9.11
87
github.com/fsnotify/fsnotify v1.9.0
98
github.com/go-logr/logr v1.4.2
@@ -37,6 +36,7 @@ require (
3736
cel.dev/expr v0.24.0 // indirect
3837
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
3938
github.com/beorn7/perks v1.0.1 // indirect
39+
github.com/blang/semver/v4 v4.0.0 // indirect
4040
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
4141
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4242
github.com/davecgh/go-spew v1.1.1 // indirect

pkg/envtest/binaries.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"sort"
3636
"strings"
3737

38-
"github.com/blang/semver/v4"
38+
"k8s.io/apimachinery/pkg/util/version"
3939
"sigs.k8s.io/yaml"
4040
)
4141

@@ -257,15 +257,15 @@ func latestStableVersionFromIndex(index *index) (string, error) {
257257
return "", fmt.Errorf("failed to find latest stable version from index: index is empty")
258258
}
259259

260-
parsedVersions := []semver.Version{}
260+
parsedVersions := []*version.Version{}
261261
for releaseVersion := range index.Releases {
262-
v, err := semver.ParseTolerant(releaseVersion)
262+
v, err := version.ParseSemantic(releaseVersion)
263263
if err != nil {
264264
return "", fmt.Errorf("failed to parse version %q: %w", releaseVersion, err)
265265
}
266266

267267
// Filter out pre-releases.
268-
if len(v.Pre) > 0 {
268+
if len(v.PreRelease()) > 0 {
269269
continue
270270
}
271271

@@ -277,7 +277,7 @@ func latestStableVersionFromIndex(index *index) (string, error) {
277277
}
278278

279279
sort.Slice(parsedVersions, func(i, j int) bool {
280-
return parsedVersions[i].GT(parsedVersions[j])
280+
return parsedVersions[i].GreaterThan(parsedVersions[j])
281281
})
282282
return "v" + parsedVersions[0].String(), nil
283283
}

0 commit comments

Comments
 (0)