File tree Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package pkg
19
19
import (
20
20
"context"
21
21
"fmt"
22
+ "net/url"
22
23
"os"
23
24
"path/filepath"
24
25
"strings"
@@ -203,14 +204,26 @@ func (session *sessionWrapper) waitForDBReady(waitTimeout int32) error {
203
204
}
204
205
205
206
func getSSLMODE (appBinding * v1alpha1.AppBinding ) (string , error ) {
206
- sslmodeString := appBinding .Spec .ClientConfig .Service .Query
207
- if sslmodeString == "" {
208
- return "" , nil
209
- }
210
- temps := strings .Split (sslmodeString , "=" )
211
- if len (temps ) != 2 {
212
- return "" , fmt .Errorf ("the sslmode is not valid. please provide the valid template. the temlpate should be like this: sslmode=<your_desire_sslmode>" )
207
+ if appBinding .Spec .ClientConfig .Service != nil {
208
+ sslmodeString := appBinding .Spec .ClientConfig .Service .Query
209
+ if sslmodeString == "" {
210
+ return "" , nil
211
+ }
212
+ temps := strings .Split (sslmodeString , "=" )
213
+ if len (temps ) != 2 {
214
+ return "" , fmt .Errorf ("the sslmode is not valid. please provide the valid template. the temlpate should be like this: sslmode=<your_desire_sslmode>" )
215
+ }
216
+ return strings .TrimSpace (temps [1 ]), nil
217
+ } else if appBinding .Spec .ClientConfig .URL != nil {
218
+ parsedURL , err := url .Parse (* appBinding .Spec .ClientConfig .URL )
219
+ if err != nil {
220
+ return "" , err
221
+ }
222
+ queryParams := parsedURL .Query ()
223
+ sslmode := queryParams .Get ("sslmode" )
224
+ klog .Infoln ("SSLMODE: " , sslmode )
225
+ return sslmode , nil
213
226
}
214
227
215
- return strings . TrimSpace ( temps [ 1 ]) , nil
228
+ return "" , nil
216
229
}
You can’t perform that action at this time.
0 commit comments