當前位置: 首頁>>代碼示例>>Golang>>正文


Golang errors.NewPullImageError函數代碼示例

本文整理匯總了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
}
開發者ID:php-coder,項目名稱:source-to-image,代碼行數:56,代碼來源:docker.go

示例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
}
開發者ID:pweil-,項目名稱:origin,代碼行數:18,代碼來源:docker.go

示例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
}
開發者ID:yarko,項目名稱:source-to-image,代碼行數:14,代碼來源:docker.go


注:本文中的github.com/openshift/source-to-image/pkg/errors.NewPullImageError函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。