From e121d5646f427eb5cbaa239bfe41d3e52954967d Mon Sep 17 00:00:00 2001 From: Gitzoz Date: Sat, 10 Feb 2018 12:19:30 +0100 Subject: [PATCH] Change naming of DatabaseHostname to LocalHostname --- .../lrazureblobdriver/lrazureblobdriver.go | 2 +- .../mongo/lreplica_drivers/lrldriver/lrldriver.go | 2 +- .../lrminiodriver/lrminiodriver.go | 2 +- .../lreplica_drivers/lrs3driver/lrs3driver.go | 4 ++-- strata/mongo/lreplica/replica.go | 14 +++++++------- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/strata/cmd/mongo/lreplica_drivers/lrazureblobdriver/lrazureblobdriver.go b/strata/cmd/mongo/lreplica_drivers/lrazureblobdriver/lrazureblobdriver.go index cba880e..13b367c 100644 --- a/strata/cmd/mongo/lreplica_drivers/lrazureblobdriver/lrazureblobdriver.go +++ b/strata/cmd/mongo/lreplica_drivers/lrazureblobdriver/lrazureblobdriver.go @@ -54,7 +54,7 @@ func (factory DriverFactory) Driver() (*strata.Driver, error) { replica, err := lreplica.NewLocalReplica( options.Replica.MaxBackgroundCopies, - options.Replica.DatabaseHostname, + options.Replica.LocalHostname, strconv.Itoa(options.Replica.Port), options.Replica.Username, options.Replica.Password, diff --git a/strata/cmd/mongo/lreplica_drivers/lrldriver/lrldriver.go b/strata/cmd/mongo/lreplica_drivers/lrldriver/lrldriver.go index 91038e4..2bd063e 100644 --- a/strata/cmd/mongo/lreplica_drivers/lrldriver/lrldriver.go +++ b/strata/cmd/mongo/lreplica_drivers/lrldriver/lrldriver.go @@ -46,7 +46,7 @@ func (factory DriverFactory) Driver() (*strata.Driver, error) { replica, err := lreplica.NewLocalReplica( options.Replica.MaxBackgroundCopies, - options.Replica.DatabaseHostname, + options.Replica.LocalHostname, strconv.Itoa(options.Replica.Port), options.Replica.Username, options.Replica.Password, diff --git a/strata/cmd/mongo/lreplica_drivers/lrminiodriver/lrminiodriver.go b/strata/cmd/mongo/lreplica_drivers/lrminiodriver/lrminiodriver.go index 45db6c6..9aa5620 100644 --- a/strata/cmd/mongo/lreplica_drivers/lrminiodriver/lrminiodriver.go +++ b/strata/cmd/mongo/lreplica_drivers/lrminiodriver/lrminiodriver.go @@ -80,7 +80,7 @@ func (factory DriverFactory) Driver() (*strata.Driver, error) { replica, err := lreplica.NewLocalReplica( options.Replica.MaxBackgroundCopies, - options.Replica.DatabaseHostname, + options.Replica.LocalHostname, strconv.Itoa(options.Replica.Port), options.Replica.Username, options.Replica.Password, diff --git a/strata/cmd/mongo/lreplica_drivers/lrs3driver/lrs3driver.go b/strata/cmd/mongo/lreplica_drivers/lrs3driver/lrs3driver.go index b04d9cb..f5fa5f1 100644 --- a/strata/cmd/mongo/lreplica_drivers/lrs3driver/lrs3driver.go +++ b/strata/cmd/mongo/lreplica_drivers/lrs3driver/lrs3driver.go @@ -27,7 +27,7 @@ type AWSOptions struct { // ReplicaOptions are used for commands like backup and restore type ReplicaOptions struct { - DatabaseHostname string `long:"database-hostname" default:"localhost" description:"Database hostname can be override with a specific hostname in most cases localhost is sufficient"` + LocalHostname string `long:"local-hostname" default:"localhost" description:"'localhost' or a hostname that is accessible on the local machine via e.g. kubernetes network"` MaxBackgroundCopies int `long:"max-background-copies" default:"16" description:"Backup and restore actions will use up to this many goroutines to copy files"` Port int `long:"port" default:"27017" description:"Backup should look for a mongod instance that is listening on this port"` Username string `long:"username" description:"If auth is configured, specify the username with admin privileges here"` @@ -72,7 +72,7 @@ func (factory DriverFactory) Driver() (*strata.Driver, error) { } replica, err := lreplica.NewLocalReplica( options.Replica.MaxBackgroundCopies, - options.Replica.DatabaseHostname, + options.Replica.LocalHostname, strconv.Itoa(options.Replica.Port), options.Replica.Username, options.Replica.Password, diff --git a/strata/mongo/lreplica/replica.go b/strata/mongo/lreplica/replica.go index 3e26a4c..7909aab 100644 --- a/strata/mongo/lreplica/replica.go +++ b/strata/mongo/lreplica/replica.go @@ -25,14 +25,14 @@ import ( ) type sessionGetter interface { - get(sslAllowInvalidCertificates bool, databaseHostname, port, username, password string) (*mgo.Session, error) + get(sslAllowInvalidCertificates bool, localHostname, port, username, password string) (*mgo.Session, error) } type localSessionGetter struct{} // port could be the empty string -func (l *localSessionGetter) get(sslAllowInvalidCertificates bool, databaseHostname, port, username, password string) (*mgo.Session, error) { - addr := databaseHostname +func (l *localSessionGetter) get(sslAllowInvalidCertificates bool, localHostname, port, username, password string) (*mgo.Session, error) { + addr := localHostname if port != "" { addr += ":" + port } @@ -68,7 +68,7 @@ func (l *localSessionGetter) get(sslAllowInvalidCertificates bool, databaseHostn // LocalReplica is a replica where all methods that take a ReplicaID must be // run on the host corresponding to ReplicaID type LocalReplica struct { - databaseHostname string + localHostname string port string username string password string @@ -78,11 +78,11 @@ type LocalReplica struct { } // NewLocalReplica constructs a LocalReplica -func NewLocalReplica(maxBackgroundCopies int, databaseHostname, port, username, password string, sslAllowInvalidCertificates bool) (*LocalReplica, error) { +func NewLocalReplica(maxBackgroundCopies int, localHostname, port, username, password string, sslAllowInvalidCertificates bool) (*LocalReplica, error) { return &LocalReplica{ sessionGetter: &localSessionGetter{}, maxBackgroundCopies: maxBackgroundCopies, - databaseHostname: databaseHostname, + localHostname: localHostname, port: port, username: username, password: password, @@ -198,7 +198,7 @@ func nestedBsonMapGet(m bson.M, arg string, moreArgs ...string) (interface{}, er // TODO(agf): Have a way to pass in tags func (r *LocalReplica) CreateSnapshot(replicaID, snapshotID string) (*strata.Snapshot, error) { strata.Log("Getting session for CreateSnapshot()") - session, err := r.sessionGetter.get(r.sslAllowInvalidCertificates, r.databaseHostname, r.port, r.username, r.password) + session, err := r.sessionGetter.get(r.sslAllowInvalidCertificates, r.localHostname, r.port, r.username, r.password) if err != nil { return nil, err }