Skip to content

Commit d0c601d

Browse files
authored
[omdb] Add command to download entire support bundle (#8072)
Adds the `omdb nexus sb download` command to download full bundle zip files. This can be used alongside `omdb nexus sb inspect -p <bundle.zip>` to inspect downloaded files.
1 parent ded072c commit d0c601d

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

dev-tools/omdb/src/bin/omdb/nexus.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,13 @@ enum SupportBundleCommands {
495495
Create,
496496
/// Delete a support bundle
497497
Delete(SupportBundleDeleteArgs),
498+
/// Download an entire support bundle
499+
Download(SupportBundleDownloadArgs),
498500
/// Download the index of a support bundle
499501
///
500502
/// This is a "list of files", from which individual files can be accessed
501503
GetIndex(SupportBundleIndexArgs),
502-
/// View a file within a support bundle
504+
/// Download a single file within a support bundle
503505
GetFile(SupportBundleFileArgs),
504506
/// Creates a dashboard for viewing the contents of a support bundle
505507
Inspect(SupportBundleInspectArgs),
@@ -510,6 +512,16 @@ struct SupportBundleDeleteArgs {
510512
id: SupportBundleUuid,
511513
}
512514

515+
#[derive(Debug, Args)]
516+
struct SupportBundleDownloadArgs {
517+
id: SupportBundleUuid,
518+
519+
/// Optional output path where the file should be written,
520+
/// instead of stdout.
521+
#[arg(short, long)]
522+
output: Option<Utf8PathBuf>,
523+
}
524+
513525
#[derive(Debug, Args)]
514526
struct SupportBundleIndexArgs {
515527
id: SupportBundleUuid,
@@ -750,6 +762,9 @@ impl NexusArgs {
750762
let token = omdb.check_allow_destructive()?;
751763
cmd_nexus_support_bundles_delete(&client, args, token).await
752764
}
765+
NexusCommands::SupportBundles(SupportBundleArgs {
766+
command: SupportBundleCommands::Download(args),
767+
}) => cmd_nexus_support_bundles_download(&client, args).await,
753768
NexusCommands::SupportBundles(SupportBundleArgs {
754769
command: SupportBundleCommands::GetIndex(args),
755770
}) => cmd_nexus_support_bundles_get_index(&client, args).await,
@@ -3854,6 +3869,28 @@ async fn write_stream_to_sink(
38543869
Ok(())
38553870
}
38563871

3872+
/// Runs `omdb nexus support-bundles download`
3873+
async fn cmd_nexus_support_bundles_download(
3874+
client: &nexus_client::Client,
3875+
args: &SupportBundleDownloadArgs,
3876+
) -> Result<(), anyhow::Error> {
3877+
let stream = client
3878+
.support_bundle_download(args.id.as_untyped_uuid())
3879+
.await
3880+
.with_context(|| format!("downloading support bundle {}", args.id))?
3881+
.into_inner_stream();
3882+
3883+
let sink: Box<dyn std::io::Write> = match &args.output {
3884+
Some(path) => Box::new(std::fs::File::create(path)?),
3885+
None => Box::new(std::io::stdout()),
3886+
};
3887+
3888+
write_stream_to_sink(stream, sink)
3889+
.await
3890+
.with_context(|| format!("streaming support bundle {}", args.id))?;
3891+
Ok(())
3892+
}
3893+
38573894
/// Runs `omdb nexus support-bundles get-index`
38583895
async fn cmd_nexus_support_bundles_get_index(
38593896
client: &nexus_client::Client,

0 commit comments

Comments
 (0)