| Index: go/src/infra/tools/cipd/remote.go
|
| diff --git a/go/src/infra/tools/cipd/remote.go b/go/src/infra/tools/cipd/remote.go
|
| index 8856d7ce57a9a8d366183939b511dd036e26712d..e395c5c0563afae2970cde76c77f0d54f037cc3a 100644
|
| --- a/go/src/infra/tools/cipd/remote.go
|
| +++ b/go/src/infra/tools/cipd/remote.go
|
| @@ -418,6 +418,30 @@ func (r *remoteImpl) attachTags(pin common.Pin, tags []string) error {
|
| return fmt.Errorf("Unexpected status when attaching tags: %s", reply.Status)
|
| }
|
|
|
| +func (r *remoteImpl) listPackages(prefix string) ([]string, error) {
|
| + endpoint, err := packageEndpoint(prefix)
|
| + if err != nil {
|
| + return nil, err
|
| + }
|
| + var reply struct {
|
| + Status string `json:"status"`
|
| + ErrorMessage string `json:"error_message"`
|
| + Packages []string `json:"packages"`
|
| + }
|
| + err = r.makeRequest(endpoint, "GET", nil, &reply)
|
| + if err != nil {
|
| + return nil, err
|
| + }
|
| + switch reply.Status {
|
| + case "SUCCESS":
|
| + out := reply.Packages
|
| + return out, nil
|
| + case "ERROR":
|
| + return nil, errors.New(reply.ErrorMessage)
|
| + }
|
| + return nil, fmt.Errorf("Unexpected list packages status: %s", reply.Status)
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| func instanceEndpoint(pin common.Pin) (string, error) {
|
| @@ -441,6 +465,12 @@ func aclEndpoint(packagePath string) (string, error) {
|
| return "repo/v1/acl?" + params.Encode(), nil
|
| }
|
|
|
| +func packageEndpoint(prefix string) (string, error) {
|
| + params := url.Values{}
|
| + params.Add("prefix", prefix)
|
| + return "repo/v1/packages?" + params.Encode(), nil
|
| +}
|
| +
|
| func tagsEndpoint(pin common.Pin, tags []string) (string, error) {
|
| err := common.ValidatePin(pin)
|
| if err != nil {
|
|
|