@@ -935,12 +935,14 @@ impl Shuttle {
935935 service : & BuiltService ,
936936 idx : u16 ,
937937 ) -> Result < Option < ( Child , runtime:: Client ) > > {
938- let crate_directory = service. crate_directory ( ) ;
939- let secrets_path = if crate_directory. join ( "Secrets.dev.toml" ) . exists ( ) {
940- crate_directory. join ( "Secrets.dev.toml" )
941- } else {
942- crate_directory. join ( "Secrets.toml" )
943- } ;
938+ let secrets_path = run_args. secret_args . secrets . clone ( ) . unwrap_or_else ( || {
939+ let crate_dir = service. crate_directory ( ) ;
940+ if crate_dir. join ( "Secrets.dev.toml" ) . exists ( ) {
941+ crate_dir. join ( "Secrets.dev.toml" )
942+ } else {
943+ crate_dir. join ( "Secrets.toml" )
944+ }
945+ } ) ;
944946 trace ! ( "Loading secrets from {}" , secrets_path. display( ) ) ;
945947
946948 let secrets: HashMap < String , String > = if let Ok ( secrets_str) = read_to_string ( secrets_path)
@@ -1610,7 +1612,7 @@ impl Shuttle {
16101612 }
16111613 }
16121614
1613- deployment_req. data = self . make_archive ( ) ?;
1615+ deployment_req. data = self . make_archive ( args . secret_args . secrets . clone ( ) ) ?;
16141616 if deployment_req. data . len ( ) > CREATE_SERVICE_BODY_LIMIT {
16151617 bail ! (
16161618 r#"The project is too large - the limit is {} MB. \
@@ -2050,7 +2052,7 @@ impl Shuttle {
20502052 Ok ( CommandOutcome :: Ok )
20512053 }
20522054
2053- fn make_archive ( & self ) -> Result < Vec < u8 > > {
2055+ fn make_archive ( & self , secrets_file : Option < PathBuf > ) -> Result < Vec < u8 > > {
20542056 let include_patterns = self . ctx . assets ( ) ;
20552057 let encoder = GzEncoder :: new ( Vec :: new ( ) , Compression :: new ( 3 ) ) ;
20562058 let mut tar = Builder :: new ( encoder) ;
@@ -2086,8 +2088,12 @@ impl Shuttle {
20862088
20872089 let mut globs = GlobSetBuilder :: new ( ) ;
20882090
2089- // Always include secrets
2090- globs. add ( Glob :: new ( "**/Secrets.toml" ) . unwrap ( ) ) ;
2091+ if let Some ( secrets_file) = secrets_file. clone ( ) {
2092+ entries. push ( secrets_file) ;
2093+ } else {
2094+ // Default: Include all Secrets.toml files
2095+ globs. add ( Glob :: new ( "**/Secrets.toml" ) . unwrap ( ) ) ;
2096+ }
20912097
20922098 // User provided includes
20932099 if let Some ( rules) = include_patterns {
@@ -2117,11 +2123,17 @@ impl Shuttle {
21172123 continue ;
21182124 }
21192125
2120- let name = path
2126+ let mut name = path
21212127 . strip_prefix ( working_directory. parent ( ) . context ( "get parent dir" ) ?)
21222128 . context ( "strip prefix of path" ) ?
21232129 . to_owned ( ) ;
21242130
2131+ // if this is the custom secrets file, rename it to Secrets.toml
2132+ if secrets_file. as_ref ( ) . is_some_and ( |sf| sf == & path) {
2133+ name. pop ( ) ;
2134+ name. push ( "Secrets.toml" ) ;
2135+ }
2136+
21252137 archive_files. insert ( path, name) ;
21262138 }
21272139
@@ -2307,7 +2319,7 @@ mod tests {
23072319 use flate2:: read:: GzDecoder ;
23082320 use tar:: Archive ;
23092321
2310- use crate :: args:: ProjectArgs ;
2322+ use crate :: args:: { DeployArgs , ProjectArgs , SecretsArgs } ;
23112323 use crate :: Shuttle ;
23122324 use std:: fs:: { self , canonicalize} ;
23132325 use std:: path:: PathBuf ;
@@ -2320,11 +2332,13 @@ mod tests {
23202332 dunce:: canonicalize ( path) . unwrap ( )
23212333 }
23222334
2323- fn get_archive_entries ( project_args : ProjectArgs ) -> Vec < String > {
2335+ fn get_archive_entries ( project_args : ProjectArgs , deploy_args : DeployArgs ) -> Vec < String > {
23242336 let mut shuttle = Shuttle :: new ( ) . unwrap ( ) ;
23252337 shuttle. load_project ( & project_args) . unwrap ( ) ;
23262338
2327- let archive = shuttle. make_archive ( ) . unwrap ( ) ;
2339+ let archive = shuttle
2340+ . make_archive ( deploy_args. secret_args . secrets )
2341+ . unwrap ( ) ;
23282342
23292343 let tar = GzDecoder :: new ( & archive[ ..] ) ;
23302344 let mut archive = Archive :: new ( tar) ;
@@ -2364,10 +2378,10 @@ mod tests {
23642378 fs:: write ( working_directory. join ( "target" ) . join ( "binary" ) , b"12345" ) . unwrap ( ) ;
23652379
23662380 let project_args = ProjectArgs {
2367- working_directory,
2381+ working_directory : working_directory . clone ( ) ,
23682382 name : Some ( "archiving-test" . to_owned ( ) ) ,
23692383 } ;
2370- let mut entries = get_archive_entries ( project_args) ;
2384+ let mut entries = get_archive_entries ( project_args. clone ( ) , Default :: default ( ) ) ;
23712385 entries. sort ( ) ;
23722386
23732387 assert_eq ! (
@@ -2390,10 +2404,43 @@ mod tests {
23902404 "src/main.rs" ,
23912405 ]
23922406 ) ;
2407+
2408+ fs:: remove_file ( working_directory. join ( "Secrets.toml" ) ) . unwrap ( ) ;
2409+ let mut entries = get_archive_entries (
2410+ project_args,
2411+ DeployArgs {
2412+ secret_args : SecretsArgs {
2413+ secrets : Some ( working_directory. join ( "Secrets.toml.example" ) ) ,
2414+ } ,
2415+ ..Default :: default ( )
2416+ } ,
2417+ ) ;
2418+ entries. sort ( ) ;
2419+
2420+ assert_eq ! (
2421+ entries,
2422+ vec![
2423+ ".gitignore" ,
2424+ ".ignore" ,
2425+ "Cargo.toml" ,
2426+ "Secrets.toml" , // got moved here
2427+ // Secrets.toml.example was the given secrets file, so it got moved
2428+ "Shuttle.toml" ,
2429+ "asset1" , // normal file
2430+ "asset2" , // .gitignore'd, but included in Shuttle.toml
2431+ // asset3 is .ignore'd
2432+ "asset4" , // .gitignore'd, but un-ignored in .ignore
2433+ "asset5" , // .ignore'd, but included in Shuttle.toml
2434+ "dist/dist1" , // .gitignore'd, but included in Shuttle.toml
2435+ "nested/static/nested1" , // normal file
2436+ // nested/static/nestedignore is .gitignore'd
2437+ "src/main.rs" ,
2438+ ]
2439+ ) ;
23932440 }
23942441
23952442 #[ test]
2396- fn load_project_returns_proper_working_directory_in_project_args ( ) {
2443+ fn finds_workspace_root ( ) {
23972444 let project_args = ProjectArgs {
23982445 working_directory : path_from_workspace_root ( "examples/axum/hello-world/src" ) ,
23992446 name : None ,
0 commit comments