// DeleteFromImageCacheDir deletes images from the cache
542783
func DeleteFromImageCacheDir(images []string) error {
	for _, image := range images {
		path := filepath.Join(constants.ImageCacheDir, image)
		path = sanitizeCacheDir(path)
		glog.Infoln("Deleting image in cache at ", path)
		if err := os.Remove(path); err != nil {
			return err
		}
	}
	return cleanImageCacheDir()
}
493515
func (c *Conn) DeleteImage(image *Image) error {
	return c.do("smugmug.images.delete", nil, "ImageID", itoa64(image.ID))
}
287194
func (c *Cache) Delete(key string) {
	c.Client.Delete(cacheKey(key))
}
540022
func (f *Facade) DeleteRegistryImage(ctx datastore.Context, image string) error {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.DeleteRegistryImage"))
	if err := f.registryStore.Delete(ctx, image); err != nil {
		return err
	}
	if err := f.zzk.DeleteRegistryImage(registry.Key(image).ID()); err != nil {
		return err
	}
	return nil
}
606947
func (f *FakeDocker) RemoveImage(name string) error {
	f.RemoveImageName = name
	return f.RemoveImageError
}
112529
func (_m *Cluster) CacheImage(ctx context.Context, podname string, nodenmae string, images []string, step int) (chan *types.CacheImageMessage, error) {
	ret := _m.Called(ctx, podname, nodenmae, images, step)

	var r0 chan *types.CacheImageMessage
	if rf, ok := ret.Get(0).(func(context.Context, string, string, []string, int) chan *types.CacheImageMessage); ok {
		r0 = rf(ctx, podname, nodenmae, images, step)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(chan *types.CacheImageMessage)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, string, string, []string, int) error); ok {
		r1 = rf(ctx, podname, nodenmae, images, step)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
374232
func CacheImagesForBootstrapper(imageRepository string, version string, clusterBootstrapper string) error {
	images := bootstrapper.GetCachedImageList(imageRepository, version, clusterBootstrapper)

	if err := CacheImages(images, constants.ImageCacheDir); err != nil {
		return errors.Wrapf(err, "Caching images for %s", clusterBootstrapper)
	}

	return nil
}
1064562
func (c *ExpirationCache) Delete(obj interface{}) error {
	key, err := c.keyFunc(obj)
	if err != nil {
		return KeyError{obj, err}
	}
	c.expirationLock.Lock()
	defer c.expirationLock.Unlock()
	c.cacheStorage.Delete(key)
	return nil
}
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
}
889388
func (c *repoCacheManager) fetchImages(tags []string) (fetchImagesResult, error) {
	images := map[string]image.Info{}

	// Create a list of images that need updating
	var toUpdate []imageToUpdate

	// Counters for reporting what happened
	var missing, refresh int
	for _, tag := range tags {
		if tag == "" {
			return fetchImagesResult{}, fmt.Errorf("empty tag in fetched tags")
		}

		// See if we have the manifest already cached
		newID := c.repoID.ToRef(tag)
		key := NewManifestKey(newID.CanonicalRef())
		bytes, deadline, err := c.cacheClient.GetKey(key)
		// If err, then we don't have it yet. Update.
		switch {
		case err != nil: // by and large these are cache misses, but any error shall count as "not found"
			if err != ErrNotCached {
				c.logger.Log("warning", "error from cache", "err", err, "ref", newID)
			}
			missing++
			toUpdate = append(toUpdate, imageToUpdate{ref: newID, previousRefresh: initialRefresh})
		case len(bytes) == 0:
			c.logger.Log("warning", "empty result from cache", "ref", newID)
			missing++
			toUpdate = append(toUpdate, imageToUpdate{ref: newID, previousRefresh: initialRefresh})
		default:
			var entry registry.ImageEntry
			if err := json.Unmarshal(bytes, &entry); err == nil {
				if c.trace {
					c.logger.Log("trace", "found cached manifest", "ref", newID, "last_fetched", entry.LastFetched.Format(time.RFC3339), "deadline", deadline.Format(time.RFC3339))
				}

				if entry.ExcludedReason == "" {
					images[tag] = entry.Info
					if c.now.After(deadline) {
						previousRefresh := minRefresh
						lastFetched := entry.Info.LastFetched
						if !lastFetched.IsZero() {
							previousRefresh = deadline.Sub(lastFetched)
						}
						toUpdate = append(toUpdate, imageToUpdate{ref: newID, previousRefresh: previousRefresh, previousDigest: entry.Info.Digest})
						refresh++
					}
				} else {
					if c.trace {
						c.logger.Log("trace", "excluded in cache", "ref", newID, "reason", entry.ExcludedReason)
					}
					if c.now.After(deadline) {
						toUpdate = append(toUpdate, imageToUpdate{ref: newID, previousRefresh: excludedRefresh})
						refresh++
					}
				}
			}
		}
	}

	result := fetchImagesResult{
		imagesFound:                images,
		imagesToUpdate:             toUpdate,
		imagesToUpdateRefreshCount: refresh,
		imagesToUpdateMissingCount: missing,
	}

	return result, nil
}
1132240
func CacheAndLoadImages(images []string) error {
	if err := CacheImages(images, constants.ImageCacheDir); err != nil {
		return err
	}
	api, err := NewAPIClient()
	if err != nil {
		return err
	}
	defer api.Close()
	h, err := api.Load(config.GetMachineName())
	if err != nil {
		return err
	}

	client, err := sshutil.NewSSHClient(h.Driver)
	if err != nil {
		return err
	}
	cmdRunner, err := bootstrapper.NewSSHRunner(client), nil
	if err != nil {
		return err
	}

	return LoadImages(cmdRunner, images, constants.ImageCacheDir)
}
603297
func (api *WebAccelAPI) DeleteCache(urls ...string) (*WebAccelDeleteCacheResponse, error) {

	type request struct {
		// URL
		URL []string
	}

	uri := fmt.Sprintf("%s/deletecache", api.getResourceURL())

	data, err := api.client.newRequest("POST", uri, &request{URL: urls})
	if err != nil {
		return nil, err
	}

	var res WebAccelDeleteCacheResponse
	if err := json.Unmarshal(data, &res); err != nil {
		return nil, err
	}
	return &res, nil
}
958528
func DeleteFromConfigMap(name string, images []string) error {
	s, err := findSetting(name)
	if err != nil {
		return err
	}
	// Set the values
	configFile, err := config.ReadConfig()
	if err != nil {
		return err
	}
	values, ok := configFile[name]
	if !ok {
		return nil
	}
	for _, image := range images {
		delete(values.(map[string]interface{}), image)
	}
	if err = s.setMap(configFile, name, values.(map[string]interface{})); err != nil {
		return err
	}
	// Write the values
	return WriteConfig(configFile)
}
245062
func DeleteCloudImageMetadata(pool *StatePool) error {
	st := pool.SystemState()
	coll, closer := st.db().GetRawCollection(cloudimagemetadataC)
	defer closer()

	bulk := coll.Bulk()
	bulk.Unordered()
	bulk.RemoveAll(bson.D{{"source", bson.D{{"$ne", "custom"}}}})
	_, err := bulk.Run()
	return errors.Annotate(err, "deleting cloud image metadata records")
}
973717
func (c *MemoryTokenCache) DeleteToken(key *CacheKey) error {
	k := key.ToMapKey()
	c.lock.Lock()
	delete(c.cache, k)
	c.lock.Unlock()
	return nil
}
184875
func (c *Cache) Delete(key string) {
	key = keyToFilename(key)
	c.d.Erase(key)
}
943720
func deleteCacheHandler(w http.ResponseWriter, r *http.Request) {
	target := r.URL.Path[len(cachePath):]
	if err := cache.Delete(target); err != nil {
		if strings.Contains((err).Error(), "not found") {
			w.WriteHeader(http.StatusNotFound)
			log.Printf("%s not found.", target)
			return
		}
		w.WriteHeader(http.StatusInternalServerError)
		log.Printf("internal cache error: %s", err)
	}
	// this is what the RFC says to use when calling DELETE.
	w.WriteHeader(http.StatusOK)
	return
}