Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --tls option #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cmd/app/index.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package app

import (
"context"
"github.com/mediocregopher/radix/v4"
"github.com/obukhov/redis-inventory/src/adapter"
"github.com/obukhov/redis-inventory/src/logger"
"github.com/obukhov/redis-inventory/src/renderer"
Expand All @@ -21,7 +19,7 @@ var indexCmd = &cobra.Command{
consoleLogger := logger.NewConsoleLogger(logLevel)
consoleLogger.Info().Msg("Start indexing")

clientSource, err := (radix.PoolConfig{}).New(context.Background(), "tcp", args[0])
clientSource, err := newPool(args[0])
if err != nil {
consoleLogger.Fatal().Err(err).Msg("Can't create redis client")
}
Expand Down Expand Up @@ -67,4 +65,5 @@ func init() {
indexCmd.Flags().StringVarP(&pattern, "pattern", "k", "*", "Glob pattern limiting the keys to be aggregated")
indexCmd.Flags().IntVarP(&scanCount, "scanCount", "c", 1000, "Number of keys to be scanned in one iteration (argument of scan command)")
indexCmd.Flags().IntVarP(&throttleNs, "throttle", "t", 0, "Throttle: number of nanoseconds to sleep between keys")
indexCmd.Flags().BoolVar(&isTLS, "tls", false, "Use TLS connection")
}
5 changes: 2 additions & 3 deletions cmd/app/inventory.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package app

import (
"context"
"os"

"github.com/mediocregopher/radix/v4"
"github.com/obukhov/redis-inventory/src/adapter"
"github.com/obukhov/redis-inventory/src/logger"
"github.com/obukhov/redis-inventory/src/renderer"
Expand All @@ -22,7 +20,7 @@ var scanCmd = &cobra.Command{
consoleLogger := logger.NewConsoleLogger(logLevel)
consoleLogger.Info().Msg("Start scanning")

clientSource, err := (radix.PoolConfig{}).New(context.Background(), "tcp", args[0])
clientSource, err := newPool(args[0])
if err != nil {
consoleLogger.Fatal().Err(err).Msg("Can't create redis client")
}
Expand Down Expand Up @@ -67,4 +65,5 @@ func init() {
scanCmd.Flags().StringVarP(&pattern, "pattern", "k", "*", "Glob pattern limiting the keys to be aggregated")
scanCmd.Flags().IntVarP(&scanCount, "scanCount", "c", 1000, "Number of keys to be scanned in one iteration (argument of scan command)")
scanCmd.Flags().IntVarP(&throttleNs, "throttle", "t", 0, "Throttle: number of nanoseconds to sleep between keys")
scanCmd.Flags().BoolVar(&isTLS, "tls", false, "Use TLS connection")
}
20 changes: 20 additions & 0 deletions cmd/app/pool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package app

import (
"context"
"crypto/tls"

"github.com/mediocregopher/radix/v4"
)

func newPool(addr string) (radix.Client, error) {
pool := radix.PoolConfig{}
if isTLS {
pool.Dialer.NetDialer = &tls.Dialer{
NetDialer: nil,
Config: nil,
}
}

return pool.New(context.Background(), "tcp", addr)
}
1 change: 1 addition & 0 deletions cmd/app/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ var (
output, outputParams, separators, pattern string
maxChildren, scanCount, throttleNs int
logLevel string
isTLS bool
)
1 change: 1 addition & 0 deletions docs/cobra/redis-inventory_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ redis-inventory index redis://[:<password>@]<host>:<port>[/<dbIndex>] [flags]
-c, --scanCount int Number of keys to be scanned in one iteration (argument of scan command) (default 1000)
-s, --separators string Symbols that logically separate levels of the key (default ":")
-t, --throttle int Throttle: number of nanoseconds to sleep between keys
--tls Use TLS connection
```

### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/cobra/redis-inventory_inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ redis-inventory inventory redis://[:<password>@]<host>:<port>[/<dbIndex>] [flags
-c, --scanCount int Number of keys to be scanned in one iteration (argument of scan command) (default 1000)
-s, --separators string Symbols that logically separate levels of the key (default ":")
-t, --throttle int Throttle: number of nanoseconds to sleep between keys
--tls Use TLS connection
```

### SEE ALSO
Expand Down