mirror of
https://github.com/regclient/regclient.git
synced 2025-09-18 07:43:15 +03:00
34 lines
918 B
Go
34 lines
918 B
Go
package regclient
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/regclient/regclient/scheme"
|
|
"github.com/regclient/regclient/types"
|
|
"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, types.ErrParsingFailed)
|
|
}
|
|
schemeAPI, err := rc.schemeGet("reg")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
rl, ok := schemeAPI.(repoLister)
|
|
if !ok {
|
|
return nil, types.ErrNotImplemented
|
|
}
|
|
return rl.RepoList(ctx, hostname, opts...)
|
|
}
|