Exemplo n.º 1
0
// PullImage pulls an image from a remote registry server, returning an error
// in case of failure.
//
// It will pull all images in parallel, so users need to make sure that the
// given buffer is safe.
func (c *Cluster) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration, nodes ...string) error {
	var w safe.Buffer
	if opts.OutputStream != nil {
		mw := io.MultiWriter(&w, opts.OutputStream)
		opts.OutputStream = mw
	} else {
		opts.OutputStream = &w
	}
	key := imageKey(opts.Repository, opts.Tag)
	_, err := c.runOnNodes(func(n node) (interface{}, error) {
		n.setPersistentClient()
		err := n.PullImage(opts, auth)
		if err != nil {
			return nil, err
		}
		img, err := n.InspectImage(key)
		if err != nil {
			return nil, err
		}
		return nil, c.storage().StoreImage(key, img.ID, n.addr)
	}, docker.ErrNoSuchImage, true, nodes...)
	if err != nil {
		return err
	}
	digest, _ := fix.GetImageDigest(w.String())
	return c.storage().SetImageDigest(key, digest)
}
Exemplo n.º 2
0
Arquivo: bs.go Projeto: botvs/tsuru
func pullBsImage(image, dockerEndpoint string, p DockerProvisioner) error {
	output, err := pullWithRetry(3, image, dockerEndpoint, p)
	if err != nil {
		return err
	}
	if shouldPinBsImage(image) {
		digest, _ := fix.GetImageDigest(output)
		image += digest
	}
	return SaveImage(image)
}
Exemplo n.º 3
0
Arquivo: bs.go Projeto: ggarnier/tsuru
func pullBsImage(image, dockerEndpoint string, p DockerProvisioner) error {
	output, err := pullWithRetry(3, image, dockerEndpoint, p)
	if err != nil {
		return err
	}
	if shouldPinBsImage(image) {
		digest, _ := fix.GetImageDigest(output)
		if digest != "" {
			image = fmt.Sprintf("%s@%s", image, digest)
		}
	}
	return SaveImage(image)
}
Exemplo n.º 4
0
func pullImage(c *nodecontainer.NodeContainerConfig, client *docker.Client, p DockerProvisioner, pool string) (string, error) {
	image := c.Image()
	output, err := pullWithRetry(client, p, image, 3)
	if err != nil {
		return "", err
	}
	digest, _ := fix.GetImageDigest(output)
	err = c.PinImageIfNeeded(image, digest, pool)
	if err != nil {
		return "", err
	}
	return image, err
}
Exemplo n.º 5
0
func (c *NodeContainerConfig) pullImage(client *docker.Client, p DockerProvisioner) (string, error) {
	image := c.image()
	output, err := pullWithRetry(client, p, image, 3)
	if err != nil {
		return "", err
	}
	var pinnedImage string
	if shouldPinImage(image) {
		digest, _ := fix.GetImageDigest(output)
		if digest != "" {
			pinnedImage = fmt.Sprintf("%s@%s", image, digest)
		}
	}
	if pinnedImage != image {
		c.PinnedImage = pinnedImage
		conf := configFor(c.Name)
		err = conf.SetField("", "pinnedimage", pinnedImage)
	}
	return image, err
}