File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 2
2
package cassandra
3
3
4
4
import (
5
- "net/url"
6
- "strings"
7
- "time"
8
-
5
+ "fmt"
9
6
"github.com/gocql/gocql"
10
7
"github.com/mattes/migrate/file"
11
8
"github.com/mattes/migrate/migrate/direction"
9
+ "net/url"
10
+ "strings"
11
+ "time"
12
12
)
13
13
14
14
type Driver struct {
@@ -50,6 +50,21 @@ func (driver *Driver) Initialize(rawurl string) error {
50
50
cluster .Consistency = gocql .All
51
51
cluster .Timeout = 1 * time .Minute
52
52
53
+ // Check if url user struct is null
54
+ if u .User != nil {
55
+ password , passwordSet := u .User .Password ()
56
+
57
+ if passwordSet == false {
58
+ return fmt .Errorf ("Missing password. Please provide password" )
59
+ }
60
+
61
+ cluster .Authenticator = gocql.PasswordAuthenticator {
62
+ Username : u .User .Username (),
63
+ Password : password ,
64
+ }
65
+
66
+ }
67
+
53
68
driver .session , err = cluster .CreateSession ()
54
69
55
70
if err != nil {
You can’t perform that action at this time.
0 commit comments