Skip to content

Commit eb9af10

Browse files
Emon46tamalsaha
authored andcommitted
Add Support for Redis when Auth is Disabled in Kubedb (#77)
Signed-off-by: Emon46 <emon@appscode.com>
1 parent bec48a2 commit eb9af10

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

pkg/util.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,23 @@ func (opt *redisOptions) newSessionWrapper(cmd string) *sessionWrapper {
8787
}
8888

8989
func (session *sessionWrapper) setDatabaseCredentials(kubeClient kubernetes.Interface, appBinding *appcatalog.AppBinding) error {
90-
appBindingSecret, err := kubeClient.CoreV1().Secrets(appBinding.Namespace).Get(context.TODO(), appBinding.Spec.Secret.Name, metav1.GetOptions{})
91-
if err != nil {
92-
return err
93-
}
90+
if appBinding.Spec.Secret != nil {
91+
appBindingSecret, err := kubeClient.CoreV1().Secrets(appBinding.Namespace).Get(context.TODO(), appBinding.Spec.Secret.Name, metav1.GetOptions{})
92+
if err != nil {
93+
return err
94+
}
9495

95-
err = appBinding.TransformSecret(kubeClient, appBindingSecret.Data)
96-
if err != nil {
97-
return err
98-
}
96+
err = appBinding.TransformSecret(kubeClient, appBindingSecret.Data)
97+
if err != nil {
98+
return err
99+
}
99100

100-
// set auth env for redis-cli
101-
session.sh.SetEnv(EnvRedisCLIAuth, string(appBindingSecret.Data[RedisPassword]))
101+
// set auth env for redis-cli
102+
session.sh.SetEnv(EnvRedisCLIAuth, string(appBindingSecret.Data[RedisPassword]))
102103

103-
// set auth env for redis-dump-go
104-
session.sh.SetEnv(EnvRedisDumpGoAuth, string(appBindingSecret.Data[RedisPassword]))
104+
// set auth env for redis-dump-go
105+
session.sh.SetEnv(EnvRedisDumpGoAuth, string(appBindingSecret.Data[RedisPassword]))
106+
}
105107

106108
return nil
107109
}

0 commit comments

Comments
 (0)