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