// FindImage returns the image for the cloudprovider, or nil if none found
541968
func (c *Channel) FindImage(provider CloudProviderID, kubernetesVersion semver.Version) *ChannelImageSpec {
	var matches []*ChannelImageSpec

	for _, image := range c.Spec.Images {
		if image.ProviderID != string(provider) {
			continue
		}
		if image.KubernetesVersion != "" {
			versionRange, err := semver.ParseRange(image.KubernetesVersion)
			if err != nil {
				glog.Warningf("cannot parse KubernetesVersion=%q", image.KubernetesVersion)
				continue
			}

			if !versionRange(kubernetesVersion) {
				glog.V(2).Infof("Kubernetes version %q does not match range: %s", kubernetesVersion, image.KubernetesVersion)
				continue
			}
		}
		matches = append(matches, image)
	}

	if len(matches) == 0 {
		glog.V(2).Infof("No matching images in channel for cloudprovider %q", provider)
		return nil
	}

	if len(matches) != 1 {
		glog.Warningf("Multiple matching images in channel for cloudprovider %q", provider)
	}
	return matches[0]
}
840397
func (d *dockerCoordinator) PullImage(image string, authOptions *docker.AuthConfiguration, callerID string, emitFn LogEventFn) (imageID string, err error) {
	// Get the future
	d.imageLock.Lock()
	future, ok := d.pullFutures[image]
	d.registerPullLogger(image, emitFn)
	if !ok {
		// Make the future
		future = newPullFuture()
		d.pullFutures[image] = future
		go d.pullImageImpl(image, authOptions, future)
	}
	d.imageLock.Unlock()

	// We unlock while we wait since this can take a while
	id, err := future.wait().result()

	d.imageLock.Lock()
	defer d.imageLock.Unlock()

	// Delete the future since we don't need it and we don't want to cache an
	// image being there if it has possibly been manually deleted (outside of
	// Nomad).
	if _, ok := d.pullFutures[image]; ok {
		delete(d.pullFutures, image)
	}

	// If we are cleaning up, we increment the reference count on the image
	if err == nil && d.cleanup {
		d.incrementImageReferenceImpl(id, image, callerID)
	}

	return id, err
}
478927
func WaitForImage(ctx context.Context, client *gophercloud.ServiceClient, imageId string) error {
	maxNumErrors := 10
	numErrors := 0

	for {
		if err := ctx.Err(); err != nil {
			return err
		}
		image, err := images.Get(client, imageId).Extract()
		if err != nil {
			errCode, ok := err.(*gophercloud.ErrUnexpectedResponseCode)
			if ok && (errCode.Actual == 500 || errCode.Actual == 404) {
				numErrors++
				if numErrors >= maxNumErrors {
					log.Printf("[ERROR] Maximum number of errors (%d) reached; failing with: %s", numErrors, err)
					return err
				}
				log.Printf("[ERROR] %d error received, will ignore and retry: %s", errCode.Actual, err)
				time.Sleep(2 * time.Second)
				continue
			}

			return err
		}

		if image.Status == "active" {
			return nil
		}

		log.Printf("Waiting for image creation status: %s", image.Status)
		time.Sleep(2 * time.Second)
	}
}
503061
func (uow *UnitOfWork) PullImage() {
	for _, container := range uow.Targeted() {
		if len(container.BuildParams().Context()) == 0 {
			container.PullImage()
		}
	}
}
243694
func (api *API) DeleteImage(img_id string) (*Image, error) {
	result := new(Image)
	url := createUrl(api, imagePathSegment, img_id)
	err := api.Client.Delete(url, nil, &result, http.StatusAccepted)
	if err != nil {
		return nil, err
	}
	result.api = api
	return result, nil
}
144800
func (c *Client) GetImage(imageID string) (*Image, error) {
	var resp Image
	req := request{
		method: client.GET,
		url:    makeURL(apiImages, imageID),
		resp:   &resp,
	}
	if _, err := c.sendRequest(req); err != nil {
		return nil, errors.Newf(err, "failed to get image with id: %s", imageID)
	}
	return &resp, nil
}
1368400
func (client *Client) DeleteImage(regionId common.Region, imageId string) error {
	args := DeleteImageArgs{
		RegionId: regionId,
		ImageId:  imageId,
	}

	response := &DeleteImageResponse{}
	return client.Invoke("DeleteImage", &args, &response)
}
1153088
func (api *IconAPI) GetImage(id int64, size string) (*sacloud.Image, error) {

	res := &sacloud.Response{}
	err := api.read(id, map[string]string{"Size": size}, res)
	if err != nil {
		return nil, err
	}
	return res.Image, nil
}
591181
func (i *ImageService) GetImage(refOrID string) (*image.Image, error) {
	ref, err := reference.ParseAnyReference(refOrID)
	if err != nil {
		return nil, errdefs.InvalidParameter(err)
	}
	namedRef, ok := ref.(reference.Named)
	if !ok {
		digested, ok := ref.(reference.Digested)
		if !ok {
			return nil, ErrImageDoesNotExist{ref}
		}
		id := image.IDFromDigest(digested.Digest())
		if img, err := i.imageStore.Get(id); err == nil {
			return img, nil
		}
		return nil, ErrImageDoesNotExist{ref}
	}

	if digest, err := i.referenceStore.Get(namedRef); err == nil {
		// Search the image stores to get the operating system, defaulting to host OS.
		id := image.IDFromDigest(digest)
		if img, err := i.imageStore.Get(id); err == nil {
			return img, nil
		}
	}

	// Search based on ID
	if id, err := i.imageStore.Search(refOrID); err == nil {
		img, err := i.imageStore.Get(id)
		if err != nil {
			return nil, ErrImageDoesNotExist{ref}
		}
		return img, nil
	}

	return nil, ErrImageDoesNotExist{ref}
}
722206
func findImageIDByName(client *gophercloud.ServiceClient, imageName string) (string, error) {
	if imageName == "" {
		return "", fmt.Errorf("empty image name")
	}

	// We have the option of filtering the image list. If we want the full
	// collection, leave it as an empty struct
	opts := images.ListOpts{Name: imageName}

	// Retrieve image list
	page, err := images.ListDetail(client, opts).AllPages()
	if err != nil {
		return "", fmt.Errorf("error on retrieving image pages: %s", err)
	}

	imageList, err := images.ExtractImages(page)
	if err != nil {
		return "", fmt.Errorf("error on extracting image list: %s", err)
	}

	if len(imageList) == 0 {
		return "", nil
	}

	if len(imageList) > 1 {
		return "", fmt.Errorf("there exists more than one image with the same name")
	}

	return imageList[0].ID, err
}
352016
func (d *driverOCI) DeleteImage(ctx context.Context, id string) error {
	_, err := d.computeClient.DeleteImage(ctx, core.DeleteImageRequest{ImageId: &id})
	return err
}
327740
func (prv *ProcessorProvider) Get(params imageserver.Params) (image.Image, error) {
	nim, err := prv.Provider.Get(params)
	if err != nil {
		return nil, err
	}
	nim, err = prv.Processor.Process(nim, params)
	if err != nil {
		return nil, err
	}
	return nim, nil
}
307207
func (f ProviderFunc) Get(params imageserver.Params) (image.Image, error) {
	return f(params)
}
245866
func (s *Service) RemoveImage(ctx context.Context, imageType options.ImageType) error {
	switch imageType {
	case "local":
		if s.Config().Image != "" {
			return nil
		}
		return image.RemoveImage(ctx, s.clientFactory.Create(s), s.imageName())
	case "all":
		return image.RemoveImage(ctx, s.clientFactory.Create(s), s.imageName())
	default:
		// Don't do a thing, should be validated up-front
		return nil
	}
}
136442
func (client *RegistryIndexClient) RemoveImage(image string) error {
	var err error
	if image, err = client.parseImage(image); err != nil {
		return err
	}
	return client.facade.DeleteRegistryImage(client.ctx, image)
}
138993
func (r *Docker) LoadImage(path string) error {
	glog.Infof("Loading image: %s", path)
	return r.Runner.Run(fmt.Sprintf("docker load -i %s", path))
}
525057
func (c Client) GetImageStreamImage(ctx context.Context, name string, options *metav1.GetOptions) (*imagev1.ImageStreamImage, error) {
	return c.ImageStreamImages.ImageStreamImages(apirequest.NamespaceValue(ctx)).Get(name, *options)
}