Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: fix parse url without http prefix #1703

Merged
merged 1 commit into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/pdctl/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package cluster_test

import (
"encoding/json"
"strings"
"testing"

. "github.com/pingcap/check"
Expand Down Expand Up @@ -45,6 +46,8 @@ func (s *clusterTestSuite) TestClusterAndPing(c *C) {
c.Assert(err, IsNil)
cluster.WaitLeader()
pdAddr := cluster.GetConfig().GetClientURLs()
i := strings.Index(pdAddr, "//")
pdAddr = pdAddr[i+2:]
cmd := pdctl.InitCommand()
defer cluster.Destroy()

Expand Down
8 changes: 7 additions & 1 deletion tools/pd-ctl/pdctl/command/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,13 @@ func getEndpoints(cmd *cobra.Command) []string {
cmd.Println("get pd address failed, should set flag with '-u'")
os.Exit(1)
}
return strings.Split(addrs, ",")
eps := strings.Split(addrs, ",")
for i, ep := range eps {
if j := strings.Index(ep, "//"); j == -1 {
eps[i] = "//" + ep
}
}
return eps
}

func postJSON(cmd *cobra.Command, prefix string, input map[string]interface{}) {
Expand Down