Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 6 additions & 3 deletions pkg/vitess/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ func constructAPIURL(settings config.VitessConfigurationSettings) (url string) {
if !strings.HasSuffix(api, "/api") {
api = fmt.Sprintf("%s/api", api)
}
url = fmt.Sprintf("%s/keyspace/%s/tablets/%s", api, settings.Keyspace, settings.Shard)

return url
validCells := ParseCells(settings)
var queryParams string
if len(validCells) > 0 {
queryParams = fmt.Sprintf("?cells=%s", strings.Join(validCells, ","))
}
return fmt.Sprintf("%s/keyspace/%s/tablets/%s%s", api, settings.Keyspace, settings.Shard, queryParams)
}

// ParseCells returns a slice of non-empty Vitess cell names
Expand Down
2 changes: 1 addition & 1 deletion pkg/vitess/api_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func TestParseTablets(t *testing.T) {
vitessApi := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.String() {
case "/api/keyspace/test/tablets/00":
case "/api/keyspace/test/tablets/00", "/api/keyspace/test/tablets/00?cells=cell2":
data, _ := json.Marshal([]Tablet{
{
Alias: &topodata.TabletAlias{Cell: "cell1"},
Expand Down