Skip to content

Commit

Permalink
Add tolerant version regex parsing to handle PostgreSQL 10.
Browse files Browse the repository at this point in the history
Closes #112.
  • Loading branch information
wrouesnel committed Oct 9, 2017
1 parent 6e3d130 commit eb054ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions postgres_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ func (cu *ColumnUsage) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

// Regex used to get the "short-version" from the postgres version field.
var versionRegex = regexp.MustCompile(`^\w+ (\d+\.\d+\.\d+)`)
var versionRegex = regexp.MustCompile(`^\w+ ((\d+)(\.\d+)?(\.\d+)?)\s`)
var lowestSupportedVersion = semver.MustParse("9.1.0")

// Parses the version of postgres into the short version string we can use to
// match behaviors.
func parseVersion(versionString string) (semver.Version, error) {
submatches := versionRegex.FindStringSubmatch(versionString)
if len(submatches) > 1 {
return semver.Make(submatches[1])
return semver.ParseTolerant(submatches[1])
}
return semver.Version{},
errors.New(fmt.Sprintln("Could not find a postgres version in string:", versionString))
Expand Down

0 comments on commit eb054ac

Please sign in to comment.