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)
| 217 | // entry. There may be more than one entries with the same key/ref combination, |
| 218 | // but those entries will have different IDs. |
| 219 | func 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 | |
| 237 | func parseCacheID(arg string) (int64, bool) { |
| 238 | id, err := strconv.ParseInt(arg, 10, 64) |