本文整理汇总了Golang中github.com/docker/distribution/registry/api/v2.ValidateRepositoryName函数的典型用法代码示例。如果您正苦于以下问题:Golang ValidateRepositoryName函数的具体用法?Golang ValidateRepositoryName怎么用?Golang ValidateRepositoryName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValidateRepositoryName函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ValidateRepositoryName
// ValidateRepositoryName validates a repository name.
func ValidateRepositoryName(reposName string) error {
if err := validateNoSchema(reposName); err != nil {
return err
}
_, remoteName := splitReposName(reposName)
return v2.ValidateRepositoryName(remoteName)
}
示例2: RepositoryScoped
// RepositoryScoped returns the scoped cache.
func (rbds *redisBlobDescriptorService) RepositoryScoped(repo string) (distribution.BlobDescriptorService, error) {
if err := v2.ValidateRepositoryName(repo); err != nil {
return nil, err
}
return &repositoryScopedRedisBlobDescriptorService{
repo: repo,
upstream: rbds,
}, nil
}
示例3: validateRemoteName
func validateRemoteName(remoteName string) error {
if !strings.Contains(remoteName, "/") {
// the repository name must not be a valid image ID
if err := image.ValidateID(remoteName); err == nil {
return fmt.Errorf("Invalid repository name (%s), cannot specify 64-byte hexadecimal strings", remoteName)
}
}
return v2.ValidateRepositoryName(remoteName)
}
示例4: RepositoryScoped
func (imbdcp *inMemoryBlobDescriptorCacheProvider) RepositoryScoped(repo string) (distribution.BlobDescriptorService, error) {
if err := v2.ValidateRepositoryName(repo); err != nil {
return nil, err
}
imbdcp.mu.RLock()
defer imbdcp.mu.RUnlock()
return &repositoryScopedInMemoryBlobDescriptorCache{
repo: repo,
parent: imbdcp,
repository: imbdcp.repositories[repo],
}, nil
}
示例5: NewRepository
// NewRepository creates a new Repository for the given repository name and base URL
func NewRepository(ctx context.Context, name, baseURL string, transport http.RoundTripper) (distribution.Repository, error) {
if err := v2.ValidateRepositoryName(name); err != nil {
return nil, err
}
ub, err := v2.NewURLBuilderFromString(baseURL)
if err != nil {
return nil, err
}
client := &http.Client{
Transport: transport,
// TODO(dmcgowan): create cookie jar
}
return &repository{
client: client,
ub: ub,
name: name,
context: ctx,
}, nil
}
示例6: Repository
// Repository returns an instance of the repository tied to the registry.
// Instances should not be shared between goroutines but are cheap to
// allocate. In general, they should be request scoped.
func (reg *registry) Repository(ctx context.Context, name string) (distribution.Repository, error) {
if err := v2.ValidateRepositoryName(name); err != nil {
return nil, distribution.ErrRepositoryNameInvalid{
Name: name,
Reason: err,
}
}
var descriptorCache distribution.BlobDescriptorService
if reg.blobDescriptorCacheProvider != nil {
var err error
descriptorCache, err = reg.blobDescriptorCacheProvider.RepositoryScoped(name)
if err != nil {
return nil, err
}
}
return &repository{
ctx: ctx,
registry: reg,
name: name,
descriptorCache: descriptorCache,
}, nil
}