From 3fd1186a10dddb91122d63336de6f7c4a42c61f3 Mon Sep 17 00:00:00 2001 From: Caleb Xu Date: Fri, 20 Jun 2025 10:00:46 -0400 Subject: [PATCH 1/2] Update to Go 1.24 Signed-off-by: Caleb Xu --- .github/workflows/go.yml | 2 +- go.mod | 2 +- go.sum | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2222a8d..454779f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version-file: go.mod diff --git a/go.mod b/go.mod index 79a627f..e69eb75 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/opdev/getocprange -go 1.20 +go 1.24 require ( github.com/Masterminds/semver/v3 v3.2.1 diff --git a/go.sum b/go.sum index e1a1c46..9bec0c2 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,7 @@ github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= @@ -34,6 +35,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -44,6 +46,7 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 8423b46ab51893728b752490ab0d210e809f53da Mon Sep 17 00:00:00 2001 From: Caleb Xu Date: Fri, 20 Jun 2025 10:34:14 -0400 Subject: [PATCH 2/2] Update lint tools and fix lint errors Signed-off-by: Caleb Xu --- Makefile | 12 ++++-------- get_ocp_range.go | 10 +++++----- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index f1ecfad..4635239 100644 --- a/Makefile +++ b/Makefile @@ -34,17 +34,13 @@ lint: golangci-lint ## Run golangci-lint linter checks. $(GOLANGCI_LINT) run GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.52.2 +GOLANGCI_LINT_VERSION ?= v2.1.6 golangci-lint: $(GOLANGCI_LINT) $(GOLANGCI_LINT): - $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)) + $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)) GOFUMPT = $(shell pwd)/bin/gofumpt -# TODO(komish): -# gofumpt pinned to 0.6.0 which is the last version to support a min go -# version of 1.20. When our min go version in go.mod is updated, we can bump -# this back to latest. -GOFUMPT_VERSION ?= v0.6.0 +GOFUMPT_VERSION ?= v0.8.0 gofumpt: ## Download envtest-setup locally if necessary. $(call go-install-tool,$(GOFUMPT),mvdan.cc/gofumpt@$(GOFUMPT_VERSION)) @@ -58,4 +54,4 @@ GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\ endef bindir: - mkdir $(PROJECT_DIR)/bin 2>/dev/null || true \ No newline at end of file + mkdir $(PROJECT_DIR)/bin 2>/dev/null || true diff --git a/get_ocp_range.go b/get_ocp_range.go index e7771db..07f1e12 100644 --- a/get_ocp_range.go +++ b/get_ocp_range.go @@ -75,7 +75,7 @@ func init() { func GetOCPRange(kubeVersionRange string) (string, error) { // Return an error if the provided range of Kubernetes versions contains unsupported operators. if strings.Contains(kubeVersionRange, "||") { - return "", fmt.Errorf("Range %s contains unsupported operator ||", kubeVersionRange) + return "", fmt.Errorf("range %s contains unsupported operator ||", kubeVersionRange) } minOCPRange, _ := semver.NewVersion("9.9") @@ -84,21 +84,21 @@ func GetOCPRange(kubeVersionRange string) (string, error) { // Ensure that the provided range of Kubernetes versions is a valid SemVer constraint. kubeVersionRangeConstraint, err := semver.NewConstraint(kubeVersionRange) if err != nil { - return "", fmt.Errorf("Error converting %s to Constraint: %v", kubeVersionRange, err) + return "", fmt.Errorf("error converting %s to Constraint: %v", kubeVersionRange, err) } for kubeVersionString, OCPVersionString := range kubeOpenShiftVersionMap { // Check which of the known Kubernetes versions validate the Constraint. kubeVersionObj, err := semver.NewVersion(kubeVersionString) if err != nil { - return "", fmt.Errorf("Error converting %s to Version: %v", kubeVersionString, err) + return "", fmt.Errorf("error converting %s to Version: %v", kubeVersionString, err) } isInRange, _ := kubeVersionRangeConstraint.Validate(kubeVersionObj) if isInRange { // Register the corresponding minimum and maximum OCP versions. OCPVersionObj, err := semver.NewVersion(OCPVersionString) if err != nil { - return "", fmt.Errorf("Error converting %s to Version: %v", OCPVersionString, err) + return "", fmt.Errorf("error converting %s to Version: %v", OCPVersionString, err) } if OCPVersionObj.LessThan(minOCPRange) { minOCPRange = OCPVersionObj @@ -112,7 +112,7 @@ func GetOCPRange(kubeVersionRange string) (string, error) { // Build the resulting range of OCP versions. if minOCPRange.Original() == "9.9" { // If the minimum was never set, it means we didn't match any known Kubernetes version. - return "", fmt.Errorf("Failed to match any known Kubernetes version to the provided range %s", kubeVersionRange) + return "", fmt.Errorf("failed to match any known Kubernetes version to the provided range %s", kubeVersionRange) } if isRangeOpenEnded(kubeVersionRangeConstraint) { // If the provided range is open-ended, the result range should also be open-ended.