Skip to content
Open
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
13 changes: 12 additions & 1 deletion drone/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ func encodeListOptions(opts ListOptions) string {
return params.Encode()
}

func asyncOpt(hasAsync bool) string {
params := url.Values{}
if hasAsync {
params.Set("async", "true")
}
return params.Encode()
}

// New returns a client at the specified url.
func New(uri string) Client {
return &client{http.DefaultClient, strings.TrimSuffix(uri, "/")}
Expand Down Expand Up @@ -190,9 +198,12 @@ func (c *client) RepoList() ([]*Repo, error) {

// RepoListSync returns a list of all repositories to which
// the user has explicit access in the host system.
func (c *client) RepoListSync() ([]*Repo, error) {
func (c *client) RepoListSync(hasAsync bool) ([]*Repo, error) {
var out []*Repo
uri := fmt.Sprintf(pathRepos, c.addr)
if hasAsync {
uri += "?" + asyncOpt(hasAsync)
}
err := c.post(uri, nil, &out)
return out, err
}
Expand Down
4 changes: 1 addition & 3 deletions drone/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func TestRepoListSync(t *testing.T) {
defer ts.Close()

client := New(ts.URL)
got, err := client.RepoListSync()
got, err := client.RepoListSync(true)
if err != nil {
t.Error(err)
return
Expand Down Expand Up @@ -681,9 +681,7 @@ func TestLogsPurge(t *testing.T) {
}
}

//
// mock server and testdata.
//
func mockHandler(w http.ResponseWriter, r *http.Request) {
routes := []struct {
verb string
Expand Down
2 changes: 1 addition & 1 deletion drone/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type Client interface {

// RepoListSync returns a list of all repositories to which
// the user has explicit access in the host system.
RepoListSync() ([]*Repo, error)
RepoListSync(hasAsync bool) ([]*Repo, error)

// RepoListAll returns a list of all repositories in
// the database. This is only available to system admins.
Expand Down