mirror of
https://github.com/regclient/regclient.git
synced 2025-04-18 22:44:00 +03:00
I feel like I need to explain, this is all to move the descriptor package. The platform package could not use the predefined errors in types because of a circular dependency from descriptor. The most appropriate way to reorg this is to move descriptor out of the type package since it was more complex than a self contained type. When doing that, type aliases were needed to avoid breaking changes to existing users. Those aliases themselves caused circular dependency loops because of the media types and errors, so those were also pulled out to separate packages. All of the old values were aliased and deprecated, and to fix the linter, those deprecations were fixed by updating the imports... everywhere. Signed-off-by: Brandon Mitchell <git@bmitch.net>
34 lines
921 B
Go
34 lines
921 B
Go
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...)
|
|
}
|