Skip to content

Commit b4e44e0

Browse files
committed
fix: conslidate use of masterminds semver across the codebase
1 parent 04c5fe2 commit b4e44e0

13 files changed

Lines changed: 90 additions & 60 deletions

File tree

aks-node-controller/go.mod

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ go 1.24.12
55
require (
66
github.com/Azure/agentbaker v0.20240503.0
77
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1
8-
github.com/blang/semver v3.5.1+incompatible
8+
github.com/Masterminds/semver/v3 v3.4.0
99
github.com/fsnotify/fsnotify v1.8.0
1010
github.com/google/go-cmp v0.7.0
1111
github.com/stretchr/testify v1.11.1
1212
google.golang.org/protobuf v1.36.6
13+
gopkg.in/yaml.v3 v3.0.1
1314
)
1415

1516
require (
1617
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
1718
github.com/Azure/go-autorest/autorest/to v0.4.1 // indirect
18-
github.com/Masterminds/semver/v3 v3.4.0 // indirect
1919
github.com/aws/aws-sdk-go-v2 v1.38.2 // indirect
2020
github.com/clarketm/json v1.17.1 // indirect
2121
github.com/coreos/butane v0.25.1 // indirect
@@ -29,7 +29,6 @@ require (
2929
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
3030
github.com/vincent-petithory/dataurl v1.0.0 // indirect
3131
golang.org/x/sys v0.40.0 // indirect
32-
gopkg.in/yaml.v3 v3.0.1 // indirect
3332
)
3433

3534
replace github.com/Azure/agentbaker => ../

aks-node-controller/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ github.com/aws/aws-sdk-go-v2 v1.38.2 h1:QUkLO1aTW0yqW95pVzZS0LGFanL71hJ0a49w4TJL
1010
github.com/aws/aws-sdk-go-v2 v1.38.2/go.mod h1:sDioUELIUO9Znk23YVmIk86/9DOpkbyyVb1i/gUNFXY=
1111
github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLoBaFpOOds6QyY1L8AX7uoY+Ln3BHc22W40X0=
1212
github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df/go.mod h1:hiVxq5OP2bUGBRNS3Z/bt/reCLFNbdcST6gISi1fiOM=
13-
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
14-
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
1513
github.com/clarketm/json v1.17.1 h1:U1IxjqJkJ7bRK4L6dyphmoO840P6bdhPdbbLySourqI=
1614
github.com/clarketm/json v1.17.1/go.mod h1:ynr2LRfb0fQU34l07csRNBTcivjySLLiY1YzQqKVfdo=
1715
github.com/coreos/butane v0.25.1 h1:Nm2WDRD7h3f6GUpazGlge1o417Z+eIC9bQlkpgVdNms=

aks-node-controller/helpers/utils.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
aksnodeconfigv1 "github.com/Azure/agentbaker/aks-node-controller/pkg/gen/aksnodeconfig/v1"
2525
"github.com/Azure/agentbaker/pkg/agent"
2626
"github.com/Azure/agentbaker/pkg/agent/datamodel"
27-
"github.com/blang/semver"
27+
"github.com/Masterminds/semver/v3"
2828
)
2929

3030
const numInPair = 2
@@ -231,9 +231,15 @@ func ValidateAndSetLinuxKubeletFlags(kubeletFlags map[string]string, cs *datamod
231231

232232
// IsKubernetesVersionGe returns true if actualVersion is greater than or equal to version.
233233
func IsKubernetesVersionGe(actualVersion, version string) bool {
234-
v1, _ := semver.Make(actualVersion)
235-
v2, _ := semver.Make(version)
236-
return v1.GE(v2)
234+
v1, err := semver.NewVersion(actualVersion)
235+
if err != nil {
236+
return false
237+
}
238+
v2, err := semver.NewVersion(version)
239+
if err != nil {
240+
return false
241+
}
242+
return v1.GreaterThanEqual(v2)
237243
}
238244

239245
func strKeyValToMapBool(str string, strDelim string, pairDelim string) map[string]bool {

e2e/go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3 v3.0.1
1818
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage/v3 v3.0.0
1919
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.2
20-
github.com/blang/semver v3.5.1+incompatible
20+
github.com/Masterminds/semver/v3 v3.4.0
2121
github.com/bramvdbogaerde/go-scp v1.6.0
2222
github.com/caarlos0/env/v11 v11.3.1
2323
github.com/coder/websocket v1.8.14
@@ -36,7 +36,6 @@ require (
3636
require (
3737
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
3838
github.com/Azure/go-autorest/autorest/to v0.4.1 // indirect
39-
github.com/Masterminds/semver/v3 v3.4.0 // indirect
4039
github.com/aws/aws-sdk-go-v2 v1.38.2 // indirect
4140
github.com/clarketm/json v1.17.1 // indirect
4241
github.com/coreos/butane v0.25.1 // indirect
@@ -60,7 +59,6 @@ require (
6059
require (
6160
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect
6261
github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 // indirect
63-
github.com/Masterminds/semver v1.5.0
6462
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
6563
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
6664
github.com/evanphx/json-patch/v5 v5.9.11 // indirect

e2e/go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJ
4242
github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE=
4343
github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 h1:XRzhVemXdgvJqCH0sFfrBUTnUJSBrBf7++ypk+twtRs=
4444
github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk=
45-
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
46-
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
4745
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
4846
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
4947
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
@@ -52,8 +50,6 @@ github.com/aws/aws-sdk-go-v2 v1.38.2 h1:QUkLO1aTW0yqW95pVzZS0LGFanL71hJ0a49w4TJL
5250
github.com/aws/aws-sdk-go-v2 v1.38.2/go.mod h1:sDioUELIUO9Znk23YVmIk86/9DOpkbyyVb1i/gUNFXY=
5351
github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLoBaFpOOds6QyY1L8AX7uoY+Ln3BHc22W40X0=
5452
github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df/go.mod h1:hiVxq5OP2bUGBRNS3Z/bt/reCLFNbdcST6gISi1fiOM=
55-
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
56-
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
5753
github.com/bramvdbogaerde/go-scp v1.6.0 h1:lDh0lUuz1dbIhJqlKLwWT7tzIRONCp1Mtx3pgQVaLQo=
5854
github.com/bramvdbogaerde/go-scp v1.6.0/go.mod h1:on2aH5AxaFb2G0N5Vsdy6B0Ml7k9HuHSwfo1y0QzAbQ=
5955
github.com/caarlos0/env/v11 v11.3.1 h1:cArPWC15hWmEt+gWk7YBi7lEXTXCvpaSdCiZE2X5mCA=

e2e/node_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"github.com/Azure/agentbaker/aks-node-controller/helpers"
99
aksnodeconfigv1 "github.com/Azure/agentbaker/aks-node-controller/pkg/gen/aksnodeconfig/v1"
10-
"github.com/Masterminds/semver"
10+
"github.com/Masterminds/semver/v3"
1111

1212
"github.com/Azure/agentbaker/e2e/config"
1313
"github.com/Azure/agentbaker/e2e/toolkit"

e2e/scenario_win_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/Azure/agentbaker/e2e/components"
1010
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
11-
"github.com/Masterminds/semver"
11+
"github.com/Masterminds/semver/v3"
1212
"github.com/stretchr/testify/require"
1313

1414
"github.com/Azure/agentbaker/e2e/config"

e2e/toolkit/k8s.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package toolkit
22

33
import (
4-
"github.com/Masterminds/semver"
4+
"github.com/Masterminds/semver/v3"
55
)
66

77
func CheckK8sConstraint(kubernetesVersion string, constraintStr string) (bool, error) {

e2e/validators.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818

1919
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
2020
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
21-
"github.com/blang/semver"
21+
"github.com/Masterminds/semver/v3"
2222
"github.com/samber/lo"
2323
"github.com/tidwall/gjson"
2424

@@ -1254,10 +1254,10 @@ func ValidateRuncVersion(ctx context.Context, s *Scenario, versions []string) {
12541254
require.Lenf(s.T, versions, 1, "Expected exactly one version for moby-runc but got %d", len(versions))
12551255
// check if versions[0] is great than or equal to 1.2.0
12561256
// check semantic version
1257-
semver, err := semver.ParseTolerant(versions[0])
1257+
parsedVersion, err := semver.NewVersion(versions[0])
12581258
require.NoError(s.T, err, "failed to parse semver from moby-runc version")
1259-
require.GreaterOrEqual(s.T, int(semver.Major), 1, "expected moby-runc major version to be at least 1, got %d", semver.Major)
1260-
require.GreaterOrEqual(s.T, int(semver.Minor), 2, "expected moby-runc minor version to be at least 2, got %d", semver.Minor)
1259+
require.GreaterOrEqual(s.T, int(parsedVersion.Major()), 1, "expected moby-runc major version to be at least 1, got %d", parsedVersion.Major())
1260+
require.GreaterOrEqual(s.T, int(parsedVersion.Minor()), 2, "expected moby-runc minor version to be at least 2, got %d", parsedVersion.Minor())
12611261
ValidateInstalledPackageVersion(ctx, s, "moby-runc", versions[0])
12621262
}
12631263

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ require (
66
github.com/Azure/go-autorest/autorest/to v0.4.1
77
github.com/Masterminds/semver/v3 v3.4.0
88
github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df
9-
github.com/blang/semver v3.5.1+incompatible
109
github.com/coreos/butane v0.25.1
1110
github.com/google/go-cmp v0.7.0
1211
github.com/gorilla/handlers v1.5.2

0 commit comments

Comments
 (0)