Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Extracts only the relevant pieces of the version string #65

Merged
merged 1 commit into from
Mar 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pkg/adaptor/rethinkdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net/url"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -56,6 +57,10 @@ type rethinkDbServerStatus struct {
Process rethinkDbProcessStatus `gorethink:"process"`
}

var (
rethinkDbVersionMatcher *regexp.Regexp = regexp.MustCompile(`\d+\.\d+(\.\d+)?`)
)

// NewRethinkdb creates a new Rethinkdb database adaptor
func NewRethinkdb(p *pipe.Pipe, path string, extra Config) (StopStartListener, error) {
var (
Expand Down Expand Up @@ -130,7 +135,16 @@ func (r *Rethinkdb) assertServerVersion(constraint version.Constraints) error {
return fmt.Errorf("could not determine the RethinkDB server version: malformed version string (%v)", serverStatus.Process.Version)
}

serverVersion, err := version.NewVersion(pieces[1])
versionString := rethinkDbVersionMatcher.FindString(pieces[1])
if versionString == "" {
return fmt.Errorf("could not determine the RethinkDB server version: malformed version string (%v)", serverStatus.Process.Version)
}

if r.debug {
fmt.Printf("RethinkDB version: %v\n", versionString)
}

serverVersion, err := version.NewVersion(versionString)
if err != nil {
return fmt.Errorf("could not determine the RethinkDB server version: malformed version string (%v)", serverStatus.Process.Version)
}
Expand Down