add user password authentication to schemagen
This commit is contained in:
committed by
Michal Jan Matczuk
parent
42b1015966
commit
3e151149a0
@@ -24,6 +24,8 @@ var (
|
|||||||
flagKeyspace = cmd.String("keyspace", "", "keyspace to inspect")
|
flagKeyspace = cmd.String("keyspace", "", "keyspace to inspect")
|
||||||
flagPkgname = cmd.String("pkgname", "models", "the name you wish to assign to your generated package")
|
flagPkgname = cmd.String("pkgname", "models", "the name you wish to assign to your generated package")
|
||||||
flagOutput = cmd.String("output", "models", "the name of the folder to output to")
|
flagOutput = cmd.String("output", "models", "the name of the folder to output to")
|
||||||
|
flagUser = cmd.String("user", "", "user for password authentication")
|
||||||
|
flagPassword = cmd.String("password", "", "password for password authentication")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -92,6 +94,12 @@ func renderTemplate(md *gocql.KeyspaceMetadata) ([]byte, error) {
|
|||||||
|
|
||||||
func createSession() (gocqlx.Session, error) {
|
func createSession() (gocqlx.Session, error) {
|
||||||
cluster := gocql.NewCluster(clusterHosts()...)
|
cluster := gocql.NewCluster(clusterHosts()...)
|
||||||
|
if *flagUser != "" {
|
||||||
|
cluster.Authenticator = gocql.PasswordAuthenticator{
|
||||||
|
Username: *flagUser,
|
||||||
|
Password: *flagPassword,
|
||||||
|
}
|
||||||
|
}
|
||||||
return gocqlx.WrapSession(cluster.CreateSession())
|
return gocqlx.WrapSession(cluster.CreateSession())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user