Skip to content

Commit

Permalink
Fix flag name from 'enableTls' -> 'enableTLS'. Make bool comparisons …
Browse files Browse the repository at this point in the history
…conform to go best practices.
  • Loading branch information
mihkelparna1 committed Feb 13, 2024
1 parent 53238d4 commit 8611688
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
17 changes: 8 additions & 9 deletions cmd/backfill-redis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var (
redisPassword = flag.String("password", "", "Password for Redis authentication")
startIndex = flag.Int("start", -1, "First index to backfill")
endIndex = flag.Int("end", -1, "Last index to backfill")
enableTls = flag.Bool("enable-tls", false, "Enable TLS for Redis client")
enableTLS = flag.Bool("enable-tls", false, "Enable TLS for Redis client")
insecureSkipVerify = flag.Bool("insecure-skip-verify", false, "Whether to skip TLS verification for Redis client or not")
rekorAddress = flag.String("rekor-address", "", "Address for Rekor, e.g. https://rekor.sigstore.dev")
versionFlag = flag.Bool("version", false, "Print the current version of Backfill Redis")
Expand Down Expand Up @@ -215,22 +215,21 @@ func redisClient() *redis.Client {
InsecureSkipVerify: *insecureSkipVerify,
}

if *enableTls == true {
if *enableTLS {
return redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%s:%s", *redisHostname, *redisPort),
Password: *redisPassword,
Network: "tcp",
TLSConfig: tlsConfig,
DB: 0, // default DB
})
} else {
return redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%s:%s", *redisHostname, *redisPort),
Password: *redisPassword,
Network: "tcp",
DB: 0, // default DB
})
}
return redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%s:%s", *redisHostname, *redisPort),
Password: *redisPassword,
Network: "tcp",
DB: 0, // default DB
})
}

// unmarshalEntryImpl decodes the base64-encoded entry to a specific entry type (types.EntryImpl).
Expand Down
15 changes: 7 additions & 8 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func ConfigureAPI(treeID uint) {
}

func NewRedisClient() *redis.Client {
if viper.GetBool("redis_server.enable-tls") == true {
if viper.GetBool("redis_server.enable-tls") {
return redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%v:%v", viper.GetString("redis_server.address"), viper.GetUint64("redis_server.port")),
Password: viper.GetString("redis_server.password"),
Expand All @@ -199,14 +199,13 @@ func NewRedisClient() *redis.Client {
},
DB: 0, // default DB
})
} else {
return redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%v:%v", viper.GetString("redis_server.address"), viper.GetUint64("redis_server.port")),
Password: viper.GetString("redis_server.password"),
Network: "tcp",
DB: 0, // default DB
})
}
return redis.NewClient(&redis.Options{
Addr: fmt.Sprintf("%v:%v", viper.GetString("redis_server.address"), viper.GetUint64("redis_server.port")),
Password: viper.GetString("redis_server.password"),
Network: "tcp",
DB: 0, // default DB
})
}

func StopAPI() {
Expand Down

0 comments on commit 8611688

Please sign in to comment.