Skip to content

Commit 72d33a8

Browse files
authored
HCPPERF-4642 : different locale issue fixed. (#28)
This change fixes the issue reported in `HCPPERF-4642` . Replacing `ssh-enabled` command with respective api call.
1 parent 16a6cb5 commit 72d33a8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

utils/cfutils.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,18 @@ func checkUserPathAvailability(app string, path string) (bool, error) {
9494
}
9595

9696
func (checker CfJavaPluginUtilImpl) CheckRequiredTools(app string) (bool, error) {
97-
output, err := exec.Command("cf", "ssh-enabled", app).Output()
97+
guid, err := exec.Command("cf", "app", app, "--guid").Output()
98+
if err != nil {
99+
return false, err
100+
}
101+
output, err := exec.Command("cf", "curl", "/v3/apps/"+strings.TrimSuffix(string(guid), "\n")+"/ssh_enabled").Output()
98102
if err != nil {
99103
return false, err
100104
}
101-
if !strings.Contains(string(output[:]), "ssh support is enabled for app '"+app+"'.") {
105+
var result map[string]interface{}
106+
json.Unmarshal([]byte(output), &result)
102107

108+
if enabled, ok := result["enabled"].(bool); !ok || !enabled {
103109
return false, errors.New("ssh is not enabled for app: '" + app + "', please run below 2 shell commands to enable ssh and try again(please note application should be restarted before take effect):\ncf enable-ssh " + app + "\ncf restart " + app)
104110
}
105111

0 commit comments

Comments
 (0)