mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-21 13:35:51 +08:00
Add --tls option to dash command (#1073)
* Add --tls option to dash command * Switch order so it works better when both --tls and --tls_server are set
This commit is contained in:
@@ -43,6 +43,7 @@ var (
|
||||
clusterAddrs string
|
||||
tlsServerName string
|
||||
insecure bool
|
||||
useTLS bool
|
||||
)
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
@@ -315,6 +316,7 @@ func init() {
|
||||
rootCmd.PersistentFlags().StringVar(&clusterAddrs, "cluster_addrs",
|
||||
"127.0.0.1:7000,127.0.0.1:7001,127.0.0.1:7002,127.0.0.1:7003,127.0.0.1:7004,127.0.0.1:7005",
|
||||
"List of comma-separated redis server addresses")
|
||||
rootCmd.PersistentFlags().BoolVar(&useTLS, "tls", false, "Enable TLS connection")
|
||||
rootCmd.PersistentFlags().StringVar(&tlsServerName, "tls_server",
|
||||
"", "Server name for TLS validation")
|
||||
rootCmd.PersistentFlags().BoolVar(&insecure, "insecure",
|
||||
@@ -326,6 +328,7 @@ func init() {
|
||||
viper.BindPFlag("username", rootCmd.PersistentFlags().Lookup("username"))
|
||||
viper.BindPFlag("cluster", rootCmd.PersistentFlags().Lookup("cluster"))
|
||||
viper.BindPFlag("cluster_addrs", rootCmd.PersistentFlags().Lookup("cluster_addrs"))
|
||||
viper.BindPFlag("tls", rootCmd.PersistentFlags().Lookup("tls"))
|
||||
viper.BindPFlag("tls_server", rootCmd.PersistentFlags().Lookup("tls_server"))
|
||||
viper.BindPFlag("insecure", rootCmd.PersistentFlags().Lookup("insecure"))
|
||||
}
|
||||
@@ -410,10 +413,15 @@ func getRedisConnOpt() asynq.RedisConnOpt {
|
||||
|
||||
func getTLSConfig() *tls.Config {
|
||||
tlsServer := viper.GetString("tls_server")
|
||||
if tlsServer == "" {
|
||||
return nil
|
||||
if tlsServer != "" {
|
||||
return &tls.Config{ServerName: tlsServer, InsecureSkipVerify: viper.GetBool("insecure")}
|
||||
}
|
||||
return &tls.Config{ServerName: tlsServer, InsecureSkipVerify: viper.GetBool("insecure")}
|
||||
|
||||
if viper.GetBool("tls") {
|
||||
return &tls.Config{InsecureSkipVerify: viper.GetBool("insecure")}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// printTable is a helper function to print data in table format.
|
||||
|
||||
Reference in New Issue
Block a user