Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -58,4 +54,4 @@ GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
endef

bindir:
mkdir $(PROJECT_DIR)/bin 2>/dev/null || true
mkdir $(PROJECT_DIR)/bin 2>/dev/null || true
10 changes: 5 additions & 5 deletions get_ocp_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/opdev/getocprange

go 1.20
go 1.24

require (
github.com/Masterminds/semver/v3 v3.2.1
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand All @@ -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=
Expand Down