Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: go/src/infra/tools/cipd/remote.go

Issue 1194803002: Add a package listing API to cipd. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 {

Powered by Google App Engine
This is Rietveld 408576698