wasmer_cli/commands/app/volumes/credentials/
rotate_secrets.rs

1use super::ItemFormatOpts;
2use crate::{
3    commands::{
4        AsyncCliCommand,
5        app::util::{AppIdent, AppIdentOpts},
6    },
7    config::WasmerEnv,
8};
9
10/// Rotate the secrets linked to volumes of an app.
11#[derive(clap::Parser, Debug)]
12pub struct CmdAppVolumesRotateSecrets {
13    #[clap(flatten)]
14    pub env: WasmerEnv,
15
16    #[clap(flatten)]
17    pub ident: AppIdentOpts,
18
19    #[clap(flatten)]
20    pub fmt: ItemFormatOpts,
21}
22
23#[async_trait::async_trait]
24impl AsyncCliCommand for CmdAppVolumesRotateSecrets {
25    type Output = ();
26
27    async fn run_async(self) -> Result<Self::Output, anyhow::Error> {
28        let client = self.env.client()?;
29        let (_ident, app) = self.ident.load_app(&client).await?;
30
31        wasmer_backend_api::query::rotate_s3_secrets(&client, app.id).await?;
32
33        // Don't print it here and leave it implied, so users can append the output
34        // of `wasmer app volumes credentials` without worrying about this message.
35        //
36        //println!(
37        //    "Correctly rotated s3 secrets for app {} ({})",
38        //    app.name,
39        //    app.owner.global_name.bold()
40        //);
41
42        super::CmdAppVolumesCredentials {
43            env: self.env,
44            fmt: self.fmt,
45            ident: AppIdentOpts {
46                app: Some(AppIdent::NamespacedName(app.owner.global_name, app.name)),
47            },
48        }
49        .run_async()
50        .await?;
51
52        Ok(())
53    }
54}