Skip to content

Commit 8e8003b

Browse files
authored
Merge pull request #124 from philbrookes/RHMAP-20508
update cli config output to match ui
2 parents ff940e4 + ffd50ea commit 8e8003b

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

cmd/mobile/main.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package main
1616

1717
import (
1818
"flag"
19-
"fmt"
2019
"os"
2120

2221
"k8s.io/client-go/kubernetes"
@@ -40,8 +39,7 @@ func main() {
4039

4140
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
4241
if err != nil {
43-
fmt.Fprintln(os.Stderr, err.Error())
44-
os.Exit(1)
42+
panic(err)
4543
}
4644
k8Client, mobileClient, scClient := NewClientsOrDie(config)
4745
var (

pkg/cmd/clientConfig.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ package cmd
1717
import (
1818
"fmt"
1919
"io"
20-
21-
"net/url"
22-
23-
"path"
20+
"regexp"
2421

2522
"github.com/aerogear/mobile-cli/pkg/cmd/output"
2623
mobile "github.com/aerogear/mobile-crd-client/pkg/client/mobile/clientset/versioned"
@@ -66,6 +63,7 @@ kubectl plugin mobile get clientconfig`,
6663
RunE: func(cmd *cobra.Command, args []string) error {
6764
var ns string
6865
var err error
66+
var dmzRegexp = regexp.MustCompile("http(s)?://.*/")
6967
ret := make([]*ServiceConfig, 0)
7068

7169
if len(args) != 1 {
@@ -94,12 +92,12 @@ kubectl plugin mobile get clientconfig`,
9492
return err
9593
}
9694
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 += "/"
10098
}
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)))
103101
}
104102
ret = append(ret, svcConfig)
105103
}

pkg/cmd/clientConfig_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ func TestClientConfigCmd_GetClientConfigCmd(t *testing.T) {
215215
},
216216
Data: map[string][]byte{
217217
"name": []byte("test-service"),
218+
"uri": []byte("https://test-service.com/test-path"),
218219
},
219220
},
220221
{
@@ -227,6 +228,7 @@ func TestClientConfigCmd_GetClientConfigCmd(t *testing.T) {
227228
},
228229
Data: map[string][]byte{
229230
"name": []byte("keycloak"),
231+
"uri": []byte("https://keycloak-service.com/keycloak-path"),
230232
},
231233
},
232234
}
@@ -264,14 +266,14 @@ func TestClientConfigCmd_GetClientConfigCmd(t *testing.T) {
264266
"id": "test-service",
265267
"name": "test-service",
266268
"type": "",
267-
"url": "https://test.com/test-service",
269+
"url": "https://test.com/mobile/test-service/test-path",
268270
"config": {}
269271
},
270272
{
271273
"id": "keycloak",
272274
"name": "keycloak",
273275
"type": "",
274-
"url": "https://test.com/keycloak",
276+
"url": "https://test.com/mobile/keycloak/keycloak-path",
275277
"config": {}
276278
}
277279
]

0 commit comments

Comments
 (0)