diff --git a/cargo-shuttle/src/lib.rs b/cargo-shuttle/src/lib.rs index 6712d01ca..eb8120b34 100644 --- a/cargo-shuttle/src/lib.rs +++ b/cargo-shuttle/src/lib.rs @@ -1724,9 +1724,34 @@ impl Shuttle { if self.beta { let manifest_path = working_directory.join("Cargo.toml"); - if !manifest_path.exists() { - bail!("Cargo manifest file not found: {}", manifest_path.display()); - } + + // Look for a secrets file, first in the command args, and if it isn't there look + // in the root of the crate or workspace. + let secrets_file = args.secret_args.secrets.clone().or_else(|| { + let secrets_file = manifest_path.parent().unwrap().join("Secrets.toml"); + + if secrets_file.exists() && secrets_file.is_file() { + Some(secrets_file) + } else { + None + } + }); + + if let Some(secrets_file) = secrets_file { + trace!("Loading secrets from {}", secrets_file.display()); + if let Ok(secrets_str) = read_to_string(&secrets_file) { + let secrets = toml::from_str::>(&secrets_str)?; + + trace!(keys = ?secrets.keys(), "available secrets"); + + deployment_req.secrets = Some(secrets); + } else { + trace!("No secrets were loaded"); + } + } else { + trace!("No secrets file was found"); + }; + let metadata = async_cargo_metadata(manifest_path.as_path()).await?; let packages = find_shuttle_packages(&metadata)?; let package_name = packages diff --git a/common/src/models/deployment.rs b/common/src/models/deployment.rs index 4402cc803..2cafa72a0 100644 --- a/common/src/models/deployment.rs +++ b/common/src/models/deployment.rs @@ -6,7 +6,7 @@ use comfy_table::{ }; use crossterm::style::Stylize; use serde::{Deserialize, Serialize}; -use std::{fmt::Display, str::FromStr}; +use std::{collections::HashMap, fmt::Display, str::FromStr}; use uuid::Uuid; use crate::deployment::{EcsState, State}; @@ -412,6 +412,8 @@ pub struct DeploymentRequest { pub data: Vec, /// The cargo package name to compile and run. Required on beta. pub package_name: Option, + /// Secrets to add before this deployment. Ignored on alpha. + pub secrets: Option>, /// Ignored on beta. pub no_test: bool, pub git_commit_id: Option,