Skip to content

Commit

Permalink
Merge pull request #268 from manavellamnimble/postgressVersion
Browse files Browse the repository at this point in the history
Error Parsing Postgres Version
  • Loading branch information
divolgin authored Sep 24, 2020
2 parents 8a30f2d + 2da1f51 commit 7fe7216
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/analyze/database_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ func compareDatabaseConditionalToActual(conditional string, result *collect.Data
return false, errors.New("unable to parse postgres connected analyzer")

case "version":
expectedRange, err := semver.ParseRange(fmt.Sprintf("%s %s", parts[1], parts[2]))
expected, err := semver.ParseTolerant(strings.Replace(parts[2], "x", "0", -1))
if err != nil {
return false, errors.Wrap(err, "failed to parse semver range")
return false, errors.Wrap(err, "failed to parse expected version")
}
actual, err := semver.ParseTolerant(strings.Replace(result.Version, "x", "0", -1))
if err != nil {
return false, errors.Wrap(err, "failed to parse postgres db actual version")
}

actual, err := semver.Parse(result.Version)
expectedRange, err := semver.ParseRange(fmt.Sprintf("%s %s", parts[1], expected.String()))
if err != nil {
return false, errors.Wrap(err, "failed to parse actual psotgres version")
return false, errors.Wrap(err, "failed to parse semver range")
}

return expectedRange(actual), nil
Expand Down

0 comments on commit 7fe7216

Please sign in to comment.