mirror of
https://github.com/hibiken/asynq.git
synced 2026-05-19 02:13:28 +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
|
clusterAddrs string
|
||||||
tlsServerName string
|
tlsServerName string
|
||||||
insecure bool
|
insecure bool
|
||||||
|
useTLS bool
|
||||||
)
|
)
|
||||||
|
|
||||||
// rootCmd represents the base command when called without any subcommands
|
// rootCmd represents the base command when called without any subcommands
|
||||||
@@ -315,6 +316,7 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().StringVar(&clusterAddrs, "cluster_addrs",
|
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",
|
"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")
|
"List of comma-separated redis server addresses")
|
||||||
|
rootCmd.PersistentFlags().BoolVar(&useTLS, "tls", false, "Enable TLS connection")
|
||||||
rootCmd.PersistentFlags().StringVar(&tlsServerName, "tls_server",
|
rootCmd.PersistentFlags().StringVar(&tlsServerName, "tls_server",
|
||||||
"", "Server name for TLS validation")
|
"", "Server name for TLS validation")
|
||||||
rootCmd.PersistentFlags().BoolVar(&insecure, "insecure",
|
rootCmd.PersistentFlags().BoolVar(&insecure, "insecure",
|
||||||
@@ -326,6 +328,7 @@ func init() {
|
|||||||
viper.BindPFlag("username", rootCmd.PersistentFlags().Lookup("username"))
|
viper.BindPFlag("username", rootCmd.PersistentFlags().Lookup("username"))
|
||||||
viper.BindPFlag("cluster", rootCmd.PersistentFlags().Lookup("cluster"))
|
viper.BindPFlag("cluster", rootCmd.PersistentFlags().Lookup("cluster"))
|
||||||
viper.BindPFlag("cluster_addrs", rootCmd.PersistentFlags().Lookup("cluster_addrs"))
|
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("tls_server", rootCmd.PersistentFlags().Lookup("tls_server"))
|
||||||
viper.BindPFlag("insecure", rootCmd.PersistentFlags().Lookup("insecure"))
|
viper.BindPFlag("insecure", rootCmd.PersistentFlags().Lookup("insecure"))
|
||||||
}
|
}
|
||||||
@@ -410,10 +413,15 @@ func getRedisConnOpt() asynq.RedisConnOpt {
|
|||||||
|
|
||||||
func getTLSConfig() *tls.Config {
|
func getTLSConfig() *tls.Config {
|
||||||
tlsServer := viper.GetString("tls_server")
|
tlsServer := viper.GetString("tls_server")
|
||||||
if tlsServer == "" {
|
if tlsServer != "" {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
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.
|
// printTable is a helper function to print data in table format.
|
||||||
|
|||||||
Reference in New Issue
Block a user