Skip to content

Commit

Permalink
Add login support for cassandra
Browse files Browse the repository at this point in the history
  • Loading branch information
Dpatel committed Jan 27, 2015
1 parent 2cf4b2c commit ee6a71d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions driver/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ee6a71d

Please sign in to comment.