mirror of
https://github.com/status-im/migrate.git
synced 2025-02-24 16:58:14 +00:00
Add login support for cassandra
This commit is contained in:
parent
2cf4b2c33e
commit
ee6a71da4c
@ -2,13 +2,13 @@
|
|||||||
package cassandra
|
package cassandra
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gocql/gocql"
|
"github.com/gocql/gocql"
|
||||||
"github.com/mattes/migrate/file"
|
"github.com/mattes/migrate/file"
|
||||||
"github.com/mattes/migrate/migrate/direction"
|
"github.com/mattes/migrate/migrate/direction"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Driver struct {
|
type Driver struct {
|
||||||
@ -50,6 +50,21 @@ func (driver *Driver) Initialize(rawurl string) error {
|
|||||||
cluster.Consistency = gocql.All
|
cluster.Consistency = gocql.All
|
||||||
cluster.Timeout = 1 * time.Minute
|
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()
|
driver.session, err = cluster.CreateSession()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user