@@ -29,17 +29,21 @@ var (
29
29
)
30
30
31
31
var (
32
- cmd = flag .NewFlagSet (os .Args [0 ], flag .ExitOnError )
33
- flagCluster = cmd .String ("cluster" , "127.0.0.1" , "a comma-separated list of host:port tuples" )
34
- flagKeyspace = cmd .String ("keyspace" , "" , "keyspace to inspect" )
35
- flagPkgname = cmd .String ("pkgname" , "models" , "the name you wish to assign to your generated package" )
36
- flagOutput = cmd .String ("output" , "models" , "the name of the folder to output to" )
37
- flagUser = cmd .String ("user" , "" , "user for password authentication" )
38
- flagPassword = cmd .String ("password" , "" , "password for password authentication" )
39
- flagIgnoreNames = cmd .String ("ignore-names" , "" , "a comma-separated list of table, view or index names to ignore" )
40
- flagIgnoreIndexes = cmd .Bool ("ignore-indexes" , false , "don't generate types for indexes" )
41
- flagQueryTimeout = cmd .Duration ("query-timeout" , defaultQueryTimeout , "query timeout ( in seconds )" )
42
- flagConnectionTimeout = cmd .Duration ("connection-timeout" , defaultConnectionTimeout , "connection timeout ( in seconds )" )
32
+ cmd = flag .NewFlagSet (os .Args [0 ], flag .ExitOnError )
33
+ flagCluster = cmd .String ("cluster" , "127.0.0.1" , "a comma-separated list of host:port tuples" )
34
+ flagKeyspace = cmd .String ("keyspace" , "" , "keyspace to inspect" )
35
+ flagPkgname = cmd .String ("pkgname" , "models" , "the name you wish to assign to your generated package" )
36
+ flagOutput = cmd .String ("output" , "models" , "the name of the folder to output to" )
37
+ flagUser = cmd .String ("user" , "" , "user for password authentication" )
38
+ flagPassword = cmd .String ("password" , "" , "password for password authentication" )
39
+ flagIgnoreNames = cmd .String ("ignore-names" , "" , "a comma-separated list of table, view or index names to ignore" )
40
+ flagIgnoreIndexes = cmd .Bool ("ignore-indexes" , false , "don't generate types for indexes" )
41
+ flagQueryTimeout = cmd .Duration ("query-timeout" , defaultQueryTimeout , "query timeout ( in seconds )" )
42
+ flagConnectionTimeout = cmd .Duration ("connection-timeout" , defaultConnectionTimeout , "connection timeout ( in seconds )" )
43
+ flagSSLEnableHostVerification = cmd .Bool ("ssl-enable-host-verification" , false , "don't check server ssl certificate" )
44
+ flagSSLCAPath = cmd .String ("ssl-ca-path" , "" , "path to ssl CA certificates" )
45
+ flagSSLCertPath = cmd .String ("ssl-cert-path" , "" , "path to ssl certificate" )
46
+ flagSSLKeyPath = cmd .String ("ssl-key-path" , "" , "path to ssl key" )
43
47
)
44
48
45
49
//go:embed keyspace.tmpl
@@ -155,18 +159,30 @@ func renderTemplate(md *gocql.KeyspaceMetadata) ([]byte, error) {
155
159
156
160
func createSession () (gocqlx.Session , error ) {
157
161
cluster := gocql .NewCluster (clusterHosts ()... )
162
+
158
163
if * flagUser != "" {
159
164
cluster .Authenticator = gocql.PasswordAuthenticator {
160
165
Username : * flagUser ,
161
166
Password : * flagPassword ,
162
167
}
163
168
}
169
+
164
170
if * flagQueryTimeout >= 0 {
165
171
cluster .Timeout = * flagQueryTimeout
166
172
}
167
173
if * flagConnectionTimeout >= 0 {
168
174
cluster .ConnectTimeout = * flagConnectionTimeout
169
175
}
176
+
177
+ if * flagSSLCAPath != "" || * flagSSLCertPath != "" || * flagSSLKeyPath != "" {
178
+ cluster .SslOpts = & gocql.SslOptions {
179
+ EnableHostVerification : * flagSSLEnableHostVerification ,
180
+ CaPath : * flagSSLCAPath ,
181
+ CertPath : * flagSSLCertPath ,
182
+ KeyPath : * flagSSLKeyPath ,
183
+ }
184
+ }
185
+
170
186
return gocqlx .WrapSession (cluster .CreateSession ())
171
187
}
172
188
0 commit comments