mirror of
https://github.com/hibiken/asynq.git
synced 2026-01-31 06:26:59 +00:00
feat: done add-username-cli (#1083)
This commit is contained in:
@@ -39,6 +39,7 @@ By default, CLI will try to connect to a redis server running at `localhost:6379
|
||||
--config string config file to set flag defaut values (default is $HOME/.asynq.yaml)
|
||||
-n, --db int redis database number (default is 0)
|
||||
-h, --help help for asynq
|
||||
-U, --username string username to use when connecting to redis server
|
||||
-p, --password string password to use when connecting to redis server
|
||||
-u, --uri string redis server URI (default "127.0.0.1:6379")
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//
|
||||
// Copyright 2020 Kentaro Hibino. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
@@ -36,6 +37,7 @@ var (
|
||||
uri string
|
||||
db int
|
||||
password string
|
||||
username string
|
||||
|
||||
useRedisCluster bool
|
||||
clusterAddrs string
|
||||
@@ -258,7 +260,6 @@ func adjustPadding(lines ...*displayLine) {
|
||||
func rpad(s string, padding int) string {
|
||||
tmpl := fmt.Sprintf("%%-%ds ", padding)
|
||||
return fmt.Sprintf(tmpl, s)
|
||||
|
||||
}
|
||||
|
||||
// lpad adds padding to the left of a string.
|
||||
@@ -309,6 +310,7 @@ func init() {
|
||||
rootCmd.PersistentFlags().StringVarP(&uri, "uri", "u", "127.0.0.1:6379", "Redis server URI")
|
||||
rootCmd.PersistentFlags().IntVarP(&db, "db", "n", 0, "Redis database number (default is 0)")
|
||||
rootCmd.PersistentFlags().StringVarP(&password, "password", "p", "", "Password to use when connecting to redis server")
|
||||
rootCmd.PersistentFlags().StringVarP(&username, "username", "U", "", "Username to use when connecting to Redis (ACL username)")
|
||||
rootCmd.PersistentFlags().BoolVar(&useRedisCluster, "cluster", false, "Connect to redis cluster")
|
||||
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",
|
||||
@@ -321,6 +323,7 @@ func init() {
|
||||
viper.BindPFlag("uri", rootCmd.PersistentFlags().Lookup("uri"))
|
||||
viper.BindPFlag("db", rootCmd.PersistentFlags().Lookup("db"))
|
||||
viper.BindPFlag("password", rootCmd.PersistentFlags().Lookup("password"))
|
||||
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_server", rootCmd.PersistentFlags().Lookup("tls_server"))
|
||||
@@ -361,6 +364,7 @@ func createRDB() *rdb.RDB {
|
||||
c = redis.NewClusterClient(&redis.ClusterOptions{
|
||||
Addrs: addrs,
|
||||
Password: viper.GetString("password"),
|
||||
Username: viper.GetString("username"),
|
||||
TLSConfig: getTLSConfig(),
|
||||
})
|
||||
} else {
|
||||
@@ -368,6 +372,7 @@ func createRDB() *rdb.RDB {
|
||||
Addr: viper.GetString("uri"),
|
||||
DB: viper.GetInt("db"),
|
||||
Password: viper.GetString("password"),
|
||||
Username: viper.GetString("username"),
|
||||
TLSConfig: getTLSConfig(),
|
||||
})
|
||||
}
|
||||
@@ -390,6 +395,7 @@ func getRedisConnOpt() asynq.RedisConnOpt {
|
||||
return asynq.RedisClusterClientOpt{
|
||||
Addrs: addrs,
|
||||
Password: viper.GetString("password"),
|
||||
Username: viper.GetString("username"),
|
||||
TLSConfig: getTLSConfig(),
|
||||
}
|
||||
}
|
||||
@@ -397,6 +403,7 @@ func getRedisConnOpt() asynq.RedisConnOpt {
|
||||
Addr: viper.GetString("uri"),
|
||||
DB: viper.GetInt("db"),
|
||||
Password: viper.GetString("password"),
|
||||
Username: viper.GetString("username"),
|
||||
TLSConfig: getTLSConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user