mirror of
https://github.com/genuinetools/reg.git
synced 2024-06-30 11:04:16 -04:00
update
Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
parent
7b01d03664
commit
e451b94f87
2
main.go
2
main.go
|
@ -105,7 +105,7 @@ func main() {
|
||||||
Usage: "list all repositories",
|
Usage: "list all repositories",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
// get the repositories via catalog
|
// get the repositories via catalog
|
||||||
repos, err := r.Catalog()
|
repos, err := r.Catalog("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,39 @@
|
||||||
package registry
|
package registry
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/peterhellberg/link"
|
||||||
|
)
|
||||||
|
|
||||||
type catalogResponse struct {
|
type catalogResponse struct {
|
||||||
Repositories []string `json:"repositories"`
|
Repositories []string `json:"repositories"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Catalog returns the repositories in a registry.
|
// Catalog returns the repositories in a registry.
|
||||||
func (r *Registry) Catalog() ([]string, error) {
|
func (r *Registry) Catalog(u string) ([]string, error) {
|
||||||
url := r.url("/v2/_catalog")
|
if u == "" {
|
||||||
|
u = "/v2/_catalog"
|
||||||
|
}
|
||||||
|
url := r.url(u)
|
||||||
r.Logf("registry.catalog url=%s", url)
|
r.Logf("registry.catalog url=%s", url)
|
||||||
|
|
||||||
var response catalogResponse
|
var response catalogResponse
|
||||||
if _, err := r.getJSON(url, &response); err != nil {
|
h, err := r.getJSON(url, &response)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
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
|
return response.Repositories, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ type v1Compatibility struct {
|
||||||
func createStaticIndex(r *registry.Registry, staticDir string) error {
|
func createStaticIndex(r *registry.Registry, staticDir string) error {
|
||||||
updating = true
|
updating = true
|
||||||
logrus.Info("fetching catalog")
|
logrus.Info("fetching catalog")
|
||||||
repoList, err := r.Catalog()
|
repoList, err := r.Catalog("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("getting catalog failed: %v", err)
|
return fmt.Errorf("getting catalog failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
8
vendor/manifest
vendored
8
vendor/manifest
vendored
|
@ -104,6 +104,14 @@
|
||||||
"path": "/libcontainer/user",
|
"path": "/libcontainer/user",
|
||||||
"notests": true
|
"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",
|
"importpath": "github.com/urfave/cli",
|
||||||
"repository": "https://github.com/urfave/cli",
|
"repository": "https://github.com/urfave/cli",
|
||||||
|
|
Loading…
Reference in a new issue