MCPcopy Index your code
hub / github.com/cargo-lambda/cargo-lambda / run

Function run

crates/cargo-lambda-deploy/src/lib.rs:39–91  ·  view source on GitHub ↗
(config: &Deploy, metadata: &CargoMetadata)

Source from the content-addressed store, hash-verified

37
38#[tracing::instrument(target = "cargo_lambda")]
39pub async fn run(config: &Deploy, metadata: &CargoMetadata) -> Result<()> {
40 tracing::trace!("deploying project");
41
42 if config.function_config.enable_function_url && config.function_config.disable_function_url {
43 return Err(miette::miette!(
44 "invalid options: --enable-function-url and --disable-function-url cannot be set together"
45 ));
46 }
47
48 let progress = Progress::start("loading binary data");
49 let (name, archive) = match load_archive(config, metadata) {
50 Ok(arc) => arc,
51 Err(err) => {
52 progress.finish_and_clear();
53 return Err(err);
54 }
55 };
56
57 let retry = RetryConfig::standard()
58 .with_retry_mode(RetryMode::Adaptive)
59 .with_max_attempts(3)
60 .with_initial_backoff(Duration::from_secs(5));
61
62 let remote_config = config.remote_config.clone().unwrap_or_default();
63 let sdk_config = remote_config.sdk_config(Some(retry)).await;
64
65 let result = if config.dry {
66 dry::DeployOutput::new(config, &name, &sdk_config, &archive).map(DeployResult::Dry)
67 } else if config.extension {
68 extensions::deploy(config, &name, &sdk_config, &archive, &progress)
69 .await
70 .map(DeployResult::Extension)
71 } else {
72 functions::deploy(config, &name, &sdk_config, &archive, &progress)
73 .await
74 .map(DeployResult::Function)
75 };
76
77 progress.finish_and_clear();
78 let output = result?;
79
80 match &config.output_format() {
81 OutputFormat::Text => println!("{output}"),
82 OutputFormat::Json => {
83 let text = to_string_pretty(&output)
84 .into_diagnostic()
85 .wrap_err("failed to serialize output into json")?;
86 println!("{text}")
87 }
88 }
89
90 Ok(())
91}
92
93fn load_archive(config: &Deploy, metadata: &CargoMetadata) -> Result<(String, BinaryArchive)> {
94 match &config.binary_path {

Callers

nothing calls this directly

Calls 6

load_archiveFunction · 0.85
newFunction · 0.85
finish_and_clearMethod · 0.80
sdk_configMethod · 0.80
deployFunction · 0.70
output_formatMethod · 0.45

Tested by

no test coverage detected