mirror of https://github.com/status-im/migrate.git
Merge pull request #30 from pateld982/master
Add authentication support for cassandra
This commit is contained in:
commit
cac6e08b44
|
@ -2,13 +2,13 @@
|
|||
package cassandra
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"fmt"
|
||||
"github.com/gocql/gocql"
|
||||
"github.com/mattes/migrate/file"
|
||||
"github.com/mattes/migrate/migrate/direction"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Driver struct {
|
||||
|
@ -50,6 +50,21 @@ func (driver *Driver) Initialize(rawurl string) error {
|
|||
cluster.Consistency = gocql.All
|
||||
cluster.Timeout = 1 * time.Minute
|
||||
|
||||
// Check if url user struct is null
|
||||
if u.User != nil {
|
||||
password, passwordSet := u.User.Password()
|
||||
|
||||
if passwordSet == false {
|
||||
return fmt.Errorf("Missing password. Please provide password")
|
||||
}
|
||||
|
||||
cluster.Authenticator = gocql.PasswordAuthenticator{
|
||||
Username: u.User.Username(),
|
||||
Password: password,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
driver.session, err = cluster.CreateSession()
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue