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)
| 214 | // entry. There may be more than one entries with the same key/ref combination, |
| 215 | // but those entries will have different IDs. |
| 216 | func 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 | |
| 230 | func parseCacheID(arg string) (int, bool) { |
| 231 | id, err := strconv.Atoi(arg) |
no test coverage detected