MCPcopy Create free account
hub / github.com/cli/cli / deleteCacheByKey

Function deleteCacheByKey

pkg/cmd/cache/delete/delete.go:219–235  ·  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

217// entry. There may be more than one entries with the same key/ref combination,
218// but those entries will have different IDs.
219func deleteCacheByKey(client *api.Client, repo ghrepo.Interface, key, ref string) (int, error) {
220 u, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "caches")
221 if err != nil {
222 return 0, err
223 }
224 u.SetQuery("key", key)
225 if ref != "" {
226 u.SetQuery("ref", ref)
227 }
228 var payload shared.CachePayload
229 err = client.REST(repo.RepoHost(), "DELETE", u.String(), nil, &payload)
230 if err != nil {
231 return 0, err
232 }
233
234 return payload.TotalCount, nil
235}
236
237func parseCacheID(arg string) (int64, bool) {
238 id, err := strconv.ParseInt(arg, 10, 64)

Callers 1

deleteCachesFunction · 0.85

Calls 7

JoinPathFunction · 0.92
SetQueryMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected