File tree 3 files changed +12
-14
lines changed
3 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ package main
16
16
17
17
import (
18
18
"flag"
19
- "fmt"
20
19
"os"
21
20
22
21
"k8s.io/client-go/kubernetes"
@@ -40,8 +39,7 @@ func main() {
40
39
41
40
config , err := clientcmd .BuildConfigFromFlags ("" , * kubeconfig )
42
41
if err != nil {
43
- fmt .Fprintln (os .Stderr , err .Error ())
44
- os .Exit (1 )
42
+ panic (err )
45
43
}
46
44
k8Client , mobileClient , scClient := NewClientsOrDie (config )
47
45
var (
Original file line number Diff line number Diff line change @@ -17,10 +17,7 @@ package cmd
17
17
import (
18
18
"fmt"
19
19
"io"
20
-
21
- "net/url"
22
-
23
- "path"
20
+ "regexp"
24
21
25
22
"github.com/aerogear/mobile-cli/pkg/cmd/output"
26
23
mobile "github.com/aerogear/mobile-crd-client/pkg/client/mobile/clientset/versioned"
@@ -66,6 +63,7 @@ kubectl plugin mobile get clientconfig`,
66
63
RunE : func (cmd * cobra.Command , args []string ) error {
67
64
var ns string
68
65
var err error
66
+ var dmzRegexp = regexp .MustCompile ("http(s)?://.*/" )
69
67
ret := make ([]* ServiceConfig , 0 )
70
68
71
69
if len (args ) != 1 {
@@ -94,12 +92,12 @@ kubectl plugin mobile get clientconfig`,
94
92
return err
95
93
}
96
94
if nil != mc && mc .Spec .DmzUrl != "" {
97
- u , err := url . Parse ( mc .Spec .DmzUrl )
98
- if err != nil {
99
- return errors . Wrap ( err , "failed to parse dmz url" )
95
+ var dmzURL = mc .Spec .DmzUrl
96
+ if dmzURL [ len ( dmzURL ) - 1 :] != "/" {
97
+ dmzURL += "/"
100
98
}
101
- u . Path = path . Join ( u . Path , svcConfig .Name )
102
- svcConfig .URL = u . String ( )
99
+ dmzURL = dmzURL + "mobile/" + svcConfig .Name + "/"
100
+ svcConfig .URL = string ( dmzRegexp . ReplaceAll ([] byte ( svcConfig . URL ), [] byte ( dmzURL )) )
103
101
}
104
102
ret = append (ret , svcConfig )
105
103
}
Original file line number Diff line number Diff line change @@ -215,6 +215,7 @@ func TestClientConfigCmd_GetClientConfigCmd(t *testing.T) {
215
215
},
216
216
Data : map [string ][]byte {
217
217
"name" : []byte ("test-service" ),
218
+ "uri" : []byte ("https://test-service.com/test-path" ),
218
219
},
219
220
},
220
221
{
@@ -227,6 +228,7 @@ func TestClientConfigCmd_GetClientConfigCmd(t *testing.T) {
227
228
},
228
229
Data : map [string ][]byte {
229
230
"name" : []byte ("keycloak" ),
231
+ "uri" : []byte ("https://keycloak-service.com/keycloak-path" ),
230
232
},
231
233
},
232
234
}
@@ -264,14 +266,14 @@ func TestClientConfigCmd_GetClientConfigCmd(t *testing.T) {
264
266
"id": "test-service",
265
267
"name": "test-service",
266
268
"type": "",
267
- "url": "https://test.com/test-service",
269
+ "url": "https://test.com/mobile/ test-service/test-path ",
268
270
"config": {}
269
271
},
270
272
{
271
273
"id": "keycloak",
272
274
"name": "keycloak",
273
275
"type": "",
274
- "url": "https://test.com/keycloak",
276
+ "url": "https://test.com/mobile/ keycloak/keycloak-path ",
275
277
"config": {}
276
278
}
277
279
]
You can’t perform that action at this time.
0 commit comments