// 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 }
// 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 }
// 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 }