mirror of
https://github.com/mii443/wasmer.git
synced 2025-08-22 16:35:33 +00:00
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
//! Get information about an edge app.
|
|
|
|
use super::util::AppIdentOpts;
|
|
use crate::{commands::AsyncCliCommand, config::WasmerEnv, opts::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)]
|
|
pub env: WasmerEnv,
|
|
|
|
#[clap(flatten)]
|
|
pub fmt: ItemFormatOpts,
|
|
|
|
#[clap(flatten)]
|
|
pub ident: AppIdentOpts,
|
|
}
|
|
|
|
#[async_trait::async_trait]
|
|
impl AsyncCliCommand for CmdAppPurgeCache {
|
|
type Output = ();
|
|
|
|
async fn run_async(self) -> Result<(), anyhow::Error> {
|
|
let client = self.env.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(())
|
|
}
|
|
}
|