mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-28 11:46:20 -04:00
update
Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
parent
7b01d03664
commit
e451b94f87
4 changed files with 34 additions and 5 deletions
2
main.go
2
main.go
|
@ -105,7 +105,7 @@ func main() {
|
|||
Usage: "list all repositories",
|
||||
Action: func(c *cli.Context) error {
|
||||
// get the repositories via catalog
|
||||
repos, err := r.Catalog()
|
||||
repos, err := r.Catalog("")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,18 +1,39 @@
|
|||
package registry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/peterhellberg/link"
|
||||
)
|
||||
|
||||
type catalogResponse struct {
|
||||
Repositories []string `json:"repositories"`
|
||||
}
|
||||
|
||||
// Catalog returns the repositories in a registry.
|
||||
func (r *Registry) Catalog() ([]string, error) {
|
||||
url := r.url("/v2/_catalog")
|
||||
func (r *Registry) Catalog(u string) ([]string, error) {
|
||||
if u == "" {
|
||||
u = "/v2/_catalog"
|
||||
}
|
||||
url := r.url(u)
|
||||
r.Logf("registry.catalog url=%s", url)
|
||||
|
||||
var response catalogResponse
|
||||
if _, err := r.getJSON(url, &response); err != nil {
|
||||
h, err := r.getJSON(url, &response)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Printf("header: %#v\n", h)
|
||||
|
||||
for _, l := range link.ParseHeader(h) {
|
||||
if l.Rel == "next" {
|
||||
repos, err := r.Catalog(l.URI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.Repositories = append(response.Repositories, repos...)
|
||||
}
|
||||
}
|
||||
|
||||
return response.Repositories, nil
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ type v1Compatibility struct {
|
|||
func createStaticIndex(r *registry.Registry, staticDir string) error {
|
||||
updating = true
|
||||
logrus.Info("fetching catalog")
|
||||
repoList, err := r.Catalog()
|
||||
repoList, err := r.Catalog("")
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting catalog failed: %v", err)
|
||||
}
|
||||
|
|
8
vendor/manifest
vendored
8
vendor/manifest
vendored
|
@ -104,6 +104,14 @@
|
|||
"path": "/libcontainer/user",
|
||||
"notests": true
|
||||
},
|
||||
{
|
||||
"importpath": "github.com/peterhellberg/link",
|
||||
"repository": "https://github.com/peterhellberg/link",
|
||||
"vcs": "git",
|
||||
"revision": "d1cebc7ea14a5fc0de7cb4a45acae773161642c6",
|
||||
"branch": "master",
|
||||
"notests": true
|
||||
},
|
||||
{
|
||||
"importpath": "github.com/urfave/cli",
|
||||
"repository": "https://github.com/urfave/cli",
|
||||
|
|
Loading…
Reference in a new issue