From 9cc43d0e32d4acf0c80a72b701d85043ecae38d9 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Mon, 8 May 2023 12:59:57 -0600 Subject: [PATCH] Add flag to change the cache version --- nix-actions-cache/src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nix-actions-cache/src/main.rs b/nix-actions-cache/src/main.rs index 5da1fc2..fa5baef 100644 --- a/nix-actions-cache/src/main.rs +++ b/nix-actions-cache/src/main.rs @@ -36,6 +36,13 @@ struct Args { /// FIXME: IPv6 #[arg(short = 'l', long, default_value = "127.0.0.1:3000")] listen: SocketAddr, + + /// The cache version. + /// + /// Only caches with the same version string are visible. + /// Using another version string allows you to "bust" the cache. + #[arg(long)] + cache_version: Option, } /// The global server state. @@ -63,7 +70,11 @@ async fn main() { .expect("Failed to load credentials from environment (see README.md)") }; - let api = Api::new(credentials).expect("Failed to initialize GitHub Actions Cache API"); + let mut api = Api::new(credentials).expect("Failed to initialize GitHub Actions Cache API"); + + if let Some(cache_version) = args.cache_version { + api.mutate_version(cache_version.as_bytes()); + } let state = Arc::new(StateInner { api });