Skip to content

Commit e11abb5

Browse files
committed
Add schemagen ssl options
1 parent 3ea85fd commit e11abb5

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

cmd/schemagen/schemagen.go

+22-9
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@ import (
2222
)
2323

2424
var (
25-
cmd = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
26-
flagCluster = cmd.String("cluster", "127.0.0.1", "a comma-separated list of host:port tuples")
27-
flagKeyspace = cmd.String("keyspace", "", "keyspace to inspect")
28-
flagPkgname = cmd.String("pkgname", "models", "the name you wish to assign to your generated package")
29-
flagOutput = cmd.String("output", "models", "the name of the folder to output to")
30-
flagUser = cmd.String("user", "", "user for password authentication")
31-
flagPassword = cmd.String("password", "", "password for password authentication")
32-
flagIgnoreNames = cmd.String("ignore-names", "", "a comma-separated list of table, view or index names to ignore")
33-
flagIgnoreIndexes = cmd.Bool("ignore-indexes", false, "don't generate types for indexes")
25+
cmd = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
26+
flagCluster = cmd.String("cluster", "127.0.0.1", "a comma-separated list of host:port tuples")
27+
flagKeyspace = cmd.String("keyspace", "", "keyspace to inspect")
28+
flagPkgname = cmd.String("pkgname", "models", "the name you wish to assign to your generated package")
29+
flagOutput = cmd.String("output", "models", "the name of the folder to output to")
30+
flagUser = cmd.String("user", "", "user for password authentication")
31+
flagPassword = cmd.String("password", "", "password for password authentication")
32+
flagIgnoreNames = cmd.String("ignore-names", "", "a comma-separated list of table, view or index names to ignore")
33+
flagIgnoreIndexes = cmd.Bool("ignore-indexes", false, "don't generate types for indexes")
34+
flagSSLEnableHostVerification = cmd.Bool("--ssl-enable-host-verification", false, "don't check server ssl certificate")
35+
flagSSLCAPath = cmd.String("--ssl-ca-path", "", "path to ssl CA certificates")
36+
flagSSLCertPath = cmd.String("--ssl-cert-path", "", "path to ssl certificate")
37+
flagSSLKeyPath = cmd.String("--ssl-key-path", "", "path to ssl key")
3438
)
3539

3640
//go:embed keyspace.tmpl
@@ -152,6 +156,15 @@ func createSession() (gocqlx.Session, error) {
152156
Password: *flagPassword,
153157
}
154158
}
159+
if *flagSSLCAPath != "" || *flagSSLCertPath != "" || *flagSSLKeyPath != "" {
160+
cluster.SslOpts = &gocql.SslOptions{
161+
EnableHostVerification: *flagSSLEnableHostVerification,
162+
CaPath: *flagSSLCAPath,
163+
CertPath: *flagSSLCertPath,
164+
KeyPath: *flagSSLKeyPath,
165+
}
166+
}
167+
155168
return gocqlx.WrapSession(cluster.CreateSession())
156169
}
157170

0 commit comments

Comments
 (0)