MCPcopy
hub / github.com/cli/cli / deleteCacheByKey

Function deleteCacheByKey

pkg/cmd/cache/delete/delete.go:216–228  ·  view source on GitHub ↗

deleteCacheByKey deletes cache entries by given key (and optional ref) and returns the number of deleted entries. Note that a key/ref combination does not necessarily map to a single cache entry. There may be more than one entries with the same key/ref combination, but those entries will have diffe

(client *api.Client, repo ghrepo.Interface, key, ref string)

Source from the content-addressed store, hash-verified

214// entry. There may be more than one entries with the same key/ref combination,
215// but those entries will have different IDs.
216func deleteCacheByKey(client *api.Client, repo ghrepo.Interface, key, ref string) (int, error) {
217 path := fmt.Sprintf("repos/%s/actions/caches?key=%s", ghrepo.FullName(repo), url.QueryEscape(key))
218 if ref != "" {
219 path += fmt.Sprintf("&ref=%s", url.QueryEscape(ref))
220 }
221 var payload shared.CachePayload
222 err := client.REST(repo.RepoHost(), "DELETE", path, nil, &payload)
223 if err != nil {
224 return 0, err
225 }
226
227 return payload.TotalCount, nil
228}
229
230func parseCacheID(arg string) (int, bool) {
231 id, err := strconv.Atoi(arg)

Callers 1

deleteCachesFunction · 0.85

Calls 3

FullNameFunction · 0.92
RESTMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected