forked from regclient/regclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
repo.go
33 lines (29 loc) · 921 Bytes
/
repo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package regclient
import (
"context"
"fmt"
"strings"
"github.com/regclient/regclient/scheme"
"github.com/regclient/regclient/types/errs"
"github.com/regclient/regclient/types/repo"
)
type repoLister interface {
RepoList(ctx context.Context, hostname string, opts ...scheme.RepoOpts) (*repo.RepoList, error)
}
// RepoList returns a list of repositories on a registry.
// Note the underlying "_catalog" API is not supported on many cloud registries.
func (rc *RegClient) RepoList(ctx context.Context, hostname string, opts ...scheme.RepoOpts) (*repo.RepoList, error) {
i := strings.Index(hostname, "/")
if i > 0 {
return nil, fmt.Errorf("invalid hostname: %s%.0w", hostname, errs.ErrParsingFailed)
}
schemeAPI, err := rc.schemeGet("reg")
if err != nil {
return nil, err
}
rl, ok := schemeAPI.(repoLister)
if !ok {
return nil, errs.ErrNotImplemented
}
return rl.RepoList(ctx, hostname, opts...)
}