Skip to content

Commit 3352561

Browse files
committed
Add simple TLS support in RedisOnlineStore
Per the go-redis docs: 'To enable TLS/SSL, you need to provide an empty tls.Config.' https://redis.uptrace.dev/guide/go-redis.html#using-tls This will allow users to append ',ssl=True' to their connection string in order to enable TLS/SSL support in the Redis client Signed-off-by: William Horton <william.horton@grandrounds.com>
1 parent e50019c commit 3352561

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

go/internal/feast/onlinestore/redisonlinestore.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package onlinestore
22

33
import (
44
"context"
5+
"crypto/tls"
56
"encoding/binary"
67
"errors"
78
"fmt"
@@ -43,6 +44,7 @@ func NewRedisOnlineStore(project string, onlineStoreConfig map[string]interface{
4344

4445
var address []string
4546
var password string
47+
var tlsConfig *tls.Config
4648
var db int // Default to 0
4749

4850
// Parse redis_type and write it into conf.t
@@ -69,8 +71,12 @@ func NewRedisOnlineStore(project string, onlineStoreConfig map[string]interface{
6971
if kv[0] == "password" {
7072
password = kv[1]
7173
} else if kv[0] == "ssl" {
72-
// TODO (woop): Add support for TLS/SSL
73-
// ssl = kv[1] == "true"
74+
result, err := strconv.ParseBool(kv[1])
75+
if err != nil {
76+
return nil, err
77+
} else if result {
78+
tlsConfig = &tls.Config{}
79+
}
7480
} else if kv[0] == "db" {
7581
db, err = strconv.Atoi(kv[1])
7682
if err != nil {
@@ -87,9 +93,10 @@ func NewRedisOnlineStore(project string, onlineStoreConfig map[string]interface{
8793

8894
if t == redisNode {
8995
store.client = redis.NewClient(&redis.Options{
90-
Addr: address[0],
91-
Password: password, // No password set
92-
DB: db,
96+
Addr: address[0],
97+
Password: password, // No password set
98+
DB: db,
99+
TLSConfig: tlsConfig,
93100
})
94101
} else {
95102
return nil, errors.New("only single node Redis is supported at this time")

0 commit comments

Comments
 (0)