Skip to content

Commit d495825

Browse files
jorsolFxKu
andauthored
Remove hardcoded VersionMap from majorversionupgrade (#3043)
Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
1 parent 2a31c40 commit d495825

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

pkg/cluster/majorversionupgrade.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"strconv"
78
"strings"
89

910
"github.com/Masterminds/semver"
@@ -14,30 +15,22 @@ import (
1415
"k8s.io/apimachinery/pkg/types"
1516
)
1617

17-
// VersionMap Map of version numbers
18-
var VersionMap = map[string]int{
19-
"14": 140000,
20-
"15": 150000,
21-
"16": 160000,
22-
"17": 170000,
23-
"18": 180000,
24-
}
25-
2618
const (
2719
majorVersionUpgradeSuccessAnnotation = "last-major-upgrade-success"
2820
majorVersionUpgradeFailureAnnotation = "last-major-upgrade-failure"
2921
)
3022

3123
// IsBiggerPostgresVersion Compare two Postgres version numbers
3224
func IsBiggerPostgresVersion(old string, new string) bool {
33-
oldN := VersionMap[old]
34-
newN := VersionMap[new]
25+
oldN, _ := strconv.Atoi(old)
26+
newN, _ := strconv.Atoi(new)
3527
return newN > oldN
3628
}
3729

3830
// GetDesiredMajorVersionAsInt Convert string to comparable integer of PG version
3931
func (c *Cluster) GetDesiredMajorVersionAsInt() int {
40-
return VersionMap[c.GetDesiredMajorVersion()]
32+
version, _ := strconv.Atoi(c.GetDesiredMajorVersion())
33+
return version * 10000
4134
}
4235

4336
// GetDesiredMajorVersion returns major version to use, incl. potential auto upgrade

0 commit comments

Comments
 (0)