本文整理汇总了Golang中github.com/openshift/source-to-image/pkg/errors.NewPullImageError函数的典型用法代码示例。如果您正苦于以下问题:Golang NewPullImageError函数的具体用法?Golang NewPullImageError怎么用?Golang NewPullImageError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewPullImageError函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PullImage
// PullImage pulls an image into the local registry
func (d *stiDocker) PullImage(name string) (*api.Image, error) {
name = getImageName(name)
// RegistryAuth is the base64 encoded credentials for the registry
base64Auth, err := base64EncodeAuth(d.pullAuth)
if err != nil {
return nil, errors.NewPullImageError(name, err)
}
err = util.TimeoutAfter(DefaultDockerTimeout, fmt.Sprintf("pulling image %q", name), func(timer *time.Timer) error {
resp, pullErr := d.client.ImagePull(context.Background(), name, dockertypes.ImagePullOptions{RegistryAuth: base64Auth})
if pullErr != nil {
return pullErr
}
defer resp.Close()
decoder := json.NewDecoder(resp)
for {
if !timer.Stop() {
return &util.TimeoutError{}
}
timer.Reset(DefaultDockerTimeout)
var msg dockermessage.JSONMessage
pullErr = decoder.Decode(&msg)
if pullErr == io.EOF {
return nil
}
if pullErr != nil {
return pullErr
}
if msg.Error != nil {
return msg.Error
}
if msg.ProgressMessage != "" {
glog.V(4).Infof("pulling image %s: %s", name, msg.ProgressMessage)
}
}
})
if err != nil {
return nil, errors.NewPullImageError(name, err)
}
inspectResp, err := d.InspectImage(name)
if err != nil {
return nil, errors.NewPullImageError(name, err)
}
if inspectResp != nil {
image := &api.Image{}
updateImageWithInspect(image, inspectResp)
return image, nil
}
return nil, nil
}
示例2: PullImage
// PullImage pulls an image into the local registry
func (d *stiDocker) PullImage(name string) (*api.Image, error) {
name = getImageName(name)
err := d.kubeDockerClient.PullImage(name, d.pullAuth, dockertypes.ImagePullOptions{})
if err != nil {
return nil, errors.NewPullImageError(name, err)
}
resp, err := d.InspectImage(name)
if err != nil {
return nil, errors.NewPullImageError(name, err)
}
if resp != nil {
image := &api.Image{}
updateImageWithInspect(image, resp)
return image, nil
}
return nil, nil
}
示例3: PullImage
// PullImage pulls an image into the local registry
func (d *stiDocker) PullImage(name string) (image *docker.Image, err error) {
name = getImageName(name)
glog.V(1).Infof("Pulling image %s", name)
// TODO: Add authentication support
if err = d.client.PullImage(docker.PullImageOptions{Repository: name}, d.pullAuth); err != nil {
glog.V(3).Infof("An error was received from the PullImage call: %v", err)
return nil, errors.NewPullImageError(name, err)
}
if image, err = d.client.InspectImage(name); err != nil {
return nil, errors.NewInspectImageError(name, err)
}
return
}