Skip to content

Commit

Permalink
Review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Aug 21, 2023
1 parent 0df272e commit a6b11d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cmd/internal/database/postgres/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"strings"
"syscall"
"time"

"github.com/Masterminds/semver/v3"
)

const (
Expand Down Expand Up @@ -195,15 +197,11 @@ func (db *Postgres) getBinaryVersion(pgConfigCmd string) (int, error) {
if !found {
return 0, fmt.Errorf("unable to detect postgres binary version in pg_config output, skipping upgrade, output:%q", binaryVersionString)
}
binaryVersionMajorString, _, found := strings.Cut(binaryVersionString, ".")
if !found {
return 0, fmt.Errorf("unable to parse postgres binary version, skipping upgrade")
}
binaryVersionMajor, err := strconv.Atoi(binaryVersionMajorString)
v, err := semver.NewVersion(binaryVersionString)
if err != nil {
return 0, fmt.Errorf("unable to parse postgres binary version to an int, skipping upgrade %w", err)
return 0, fmt.Errorf("unable to parse postgres binary version %w", err)
}
return binaryVersionMajor, nil
return int(v.Major()), nil
}

func (db *Postgres) getDatabaseVersion(pgVersionFile string) (int, error) {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.21

require (
cloud.google.com/go/storage v1.32.0
github.com/Masterminds/semver/v3 v3.2.1
github.com/aws/aws-sdk-go v1.44.324
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/metal-stack/v v1.0.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ cloud.google.com/go/storage v1.32.0/go.mod h1:Hhh/dogNRGca7IWv1RC2YqEn0c0G77ctA/
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
Expand Down

0 comments on commit a6b11d0

Please sign in to comment.