-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4810 from wasmerio/issue-4795-cli-app-cache-purge
feat(cli): Add "app purge-cache" command
- Loading branch information
Showing
7 changed files
with
152 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//! Get information about an edge app. | ||
use super::util::AppIdentOpts; | ||
use crate::{ | ||
commands::AsyncCliCommand, | ||
opts::{ApiOpts, ItemFormatOpts}, | ||
}; | ||
|
||
/// Purge caches for applications. | ||
/// | ||
/// Cache scopes that can be cleared: | ||
/// * InstaBoot startup snapshots | ||
/// Will delete all existing snapshots. | ||
/// New snapshots will be created automatically. | ||
#[derive(clap::Parser, Debug)] | ||
pub struct CmdAppPurgeCache { | ||
#[clap(flatten)] | ||
#[allow(missing_docs)] | ||
pub api: ApiOpts, | ||
#[clap(flatten)] | ||
#[allow(missing_docs)] | ||
pub fmt: ItemFormatOpts, | ||
|
||
#[clap(flatten)] | ||
#[allow(missing_docs)] | ||
pub ident: AppIdentOpts, | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl AsyncCliCommand for CmdAppPurgeCache { | ||
type Output = (); | ||
|
||
async fn run_async(self) -> Result<(), anyhow::Error> { | ||
let client = self.api.client()?; | ||
let (_ident, app) = self.ident.load_app(&client).await?; | ||
|
||
let version_id = app.active_version.id; | ||
|
||
let name = format!("{} ({})", app.name, app.owner.global_name); | ||
|
||
println!( | ||
"Purging caches for {}, app version {}...", | ||
name, | ||
version_id.inner() | ||
); | ||
|
||
let vars = wasmer_api::types::PurgeCacheForAppVersionVars { id: version_id }; | ||
wasmer_api::query::purge_cache_for_app_version(&client, vars).await?; | ||
|
||
println!("🚽 swirl! All caches have been purged!"); | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters