Skip to content

Commit d91ecdb

Browse files
1gtmEmruz Hossain
andauthored
[cherry-pick] Only set "PGSSLMODE" mode env variable when SSL is enabled (#801) (#806)
/cherry-pick Signed-off-by: Emruz Hossain <emruz@appscode.com> Co-authored-by: Emruz Hossain <emruz@appscode.com>
1 parent 788fde1 commit d91ecdb

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pkg/util.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ func (opt *postgresOptions) waitForDBReady(appBinding *v1alpha1.AppBinding, secr
128128
if err != nil {
129129
return err
130130
}
131-
shell.SetEnv(EnvPGSSLMODE, pgSSlmode)
131+
// Only set "PGSSLMODE" mode env variable, if it has been provided in the AppBinding.
132+
if pgSSlmode != "" {
133+
shell.SetEnv(EnvPGSSLMODE, pgSSlmode)
134+
}
132135

133136
//shell.SetEnv(EnvPgPassword, must(meta_util.GetBytesForKeys(secret.Data, core.BasicAuthPasswordKey, envPostgresPassword)))
134137
args := []interface{}{
@@ -142,8 +145,10 @@ func (opt *postgresOptions) waitForDBReady(appBinding *v1alpha1.AppBinding, secr
142145
}
143146

144147
func getSSLMODE(appBinding *v1alpha1.AppBinding) (string, error) {
145-
146148
sslmodeString := appBinding.Spec.ClientConfig.Service.Query
149+
if sslmodeString == "" {
150+
return "", nil
151+
}
147152
temps := strings.Split(sslmodeString, "=")
148153
if len(temps) != 2 {
149154
return "", fmt.Errorf("the sslmode is not valid. please provide the valid template. the temlpate should be like this: sslmode=<your_desire_sslmode>")
@@ -198,6 +203,9 @@ func (opt *postgresOptions) GetResticWrapperWithPGConnectorVariables(appBinding
198203
if err != nil {
199204
return nil, userName, err
200205
}
201-
resticWrapper.SetEnv(EnvPGSSLMODE, pgSSlmode)
206+
// Only set "PGSSLMODE" mode env variable, if it has been provided in the AppBinding.
207+
if pgSSlmode != "" {
208+
resticWrapper.SetEnv(EnvPGSSLMODE, pgSSlmode)
209+
}
202210
return resticWrapper, userName, nil
203211
}

0 commit comments

Comments
 (0)