本文整理汇总了Golang中github.com/docker/distribution/registry/client/transport.NewHTTPReadSeeker函数的典型用法代码示例。如果您正苦于以下问题:Golang NewHTTPReadSeeker函数的具体用法?Golang NewHTTPReadSeeker怎么用?Golang NewHTTPReadSeeker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewHTTPReadSeeker函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: open
func (ld *v2LayerDescriptor) open(ctx context.Context) (distribution.ReadSeekCloser, error) {
if len(ld.src.URLs) == 0 {
blobs := ld.repo.Blobs(ctx)
return blobs.Open(ctx, ld.digest)
}
var (
err error
rsc distribution.ReadSeekCloser
)
// Find the first URL that results in a 200 result code.
for _, url := range ld.src.URLs {
logrus.Debugf("Pulling %v from foreign URL %v", ld.digest, url)
rsc = transport.NewHTTPReadSeeker(http.DefaultClient, url, nil)
_, err = rsc.Seek(0, os.SEEK_SET)
if err == nil {
break
}
logrus.Debugf("Download for %v failed: %v", ld.digest, err)
rsc.Close()
rsc = nil
}
return rsc, err
}
开发者ID:SUSE,项目名称:docker.mirror,代码行数:25,代码来源:pull_v2_windows.go
示例2: Open
func (bs *blobs) Open(ctx context.Context, dgst digest.Digest) (distribution.ReadSeekCloser, error) {
stat, err := bs.statter.Stat(ctx, dgst)
if err != nil {
return nil, err
}
blobURL, err := bs.ub.BuildBlobURL(bs.name, stat.Digest)
if err != nil {
return nil, err
}
return transport.NewHTTPReadSeeker(bs.client, blobURL, stat.Size), nil
}
开发者ID:TomDeVito,项目名称:distribution,代码行数:13,代码来源:repository.go
示例3: Open
func (bs *blobs) Open(ctx context.Context, dgst digest.Digest) (distribution.ReadSeekCloser, error) {
blobURL, err := bs.ub.BuildBlobURL(bs.name, dgst)
if err != nil {
return nil, err
}
return transport.NewHTTPReadSeeker(bs.client, blobURL,
func(resp *http.Response) error {
if resp.StatusCode == http.StatusNotFound {
return distribution.ErrBlobUnknown
}
return HandleErrorResponse(resp)
}), nil
}
开发者ID:rkazak,项目名称:distribution,代码行数:14,代码来源:repository.go
示例4: getBlob
func (r *registry) getBlob(ctx context.Context, name reference.Named, dgst digest.Digest) ([]byte, error) {
ref, err := reference.WithDigest(name, dgst)
if err != nil {
return nil, err
}
blobURL, err := r.ub.BuildBlobURL(ref)
if err != nil {
return nil, err
}
reader := transport.NewHTTPReadSeeker(r.client, blobURL,
func(resp *http.Response) error {
if resp.StatusCode == http.StatusNotFound {
return distribution.ErrBlobUnknown
}
return client.HandleErrorResponse(resp)
})
defer reader.Close()
return ioutil.ReadAll(reader)
}
开发者ID:opentable,项目名称:sous,代码行数:21,代码来源:client.go
注:本文中的github.com/docker/distribution/registry/client/transport.NewHTTPReadSeeker函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论