Skip to content
This repository was archived by the owner on May 28, 2021. It is now read-only.

Commit 9d02772

Browse files
committed
Change to use semver to compare version
Not realized there already have semver can use before. Signed-off-by: Alan Tang <alantang888@gmail.com>
1 parent aa5924e commit 9d02772

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

pkg/resources/statefulsets/statefulset.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
"github.com/oracle/mysql-operator/pkg/resources/secrets"
3535
"github.com/oracle/mysql-operator/pkg/version"
3636

37-
goverion "github.com/hashicorp/go-version"
37+
"github.com/coreos/go-semver/semver"
3838
)
3939

4040
const (
@@ -159,22 +159,24 @@ func getReplicationGroupSeeds(name string, members int) string {
159159
return strings.Join(seeds, ",")
160160
}
161161

162-
func checkSupportGroupExitStateArgs(deployingVersion string) bool {
163-
ver, err := goverion.NewVersion(deployingVersion)
164-
if err != nil {
165-
return false
166-
}
162+
func checkSupportGroupExitStateArgs(deployingVersion string) (supportedVer bool) {
163+
defer func() {
164+
if r := recover(); r != nil {
167165

168-
minVer, err := goverion.NewVersion(minMysqlVersionWithGroupExitStateArgs)
169-
if err != nil {
170-
return false
171-
}
166+
}
167+
}()
168+
169+
supportedVer = false
170+
171+
ver := semver.New(deployingVersion)
172+
minVer := semver.New(minMysqlVersionWithGroupExitStateArgs)
172173

173-
if ver.GreaterThan(minVer) || ver.Equal(minVer) {
174-
return true
174+
if ver.LessThan(*minVer) {
175+
return
175176
}
176177

177-
return false
178+
supportedVer = true
179+
return
178180
}
179181

180182
// Builds the MySQL operator container for a cluster.

0 commit comments

Comments
 (0)