Skip to content

Commit

Permalink
feat(cargo-shuttle): Shuttle.toml new key names (#1895)
Browse files Browse the repository at this point in the history
* feat(cargo-shuttle): Shuttle.toml rename assets->deploy.include, build_assets->build.assets

* clippy
  • Loading branch information
jonaro00 authored Oct 3, 2024
1 parent 1e90f20 commit 4820498
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 23 additions & 6 deletions cargo-shuttle/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,27 @@ impl GlobalConfig {
pub struct ProjectConfig {
// unused on new platform
pub name: Option<String>,
// deprecated name
pub assets: Option<Vec<String>>,
// unused in cargo-shuttle, used in new platform builder.
// is used here to validate the type if used.
pub build_assets: Option<Vec<String>>,

pub deploy: Option<ProjectDeployConfig>,
pub build: Option<ProjectBuildConfig>,
}
/// Deployment command config
#[derive(Deserialize, Serialize, Default)]
pub struct ProjectDeployConfig {
/// Successor to `assets`.
/// Patterns of ignored files that should be included in deployments.
pub include: Option<Vec<String>>,
/// set to true to deny deployments with uncommited changes. (can use `--allow-dirty`)
pub deny_dirty: Option<bool>,
}
/// Builder config
#[derive(Deserialize, Serialize, Default)]
pub struct ProjectBuildConfig {
/// Successor to `build_assets`.
/// Patterns of files that should be copied from the build to the runtime container.
pub assets: Option<Vec<String>>,
}

/// .shuttle/config.toml schema (internal project-local config)
#[derive(Deserialize, Serialize, Default)]
Expand Down Expand Up @@ -485,14 +493,23 @@ impl RequestContext {

/// # Panics
/// Panics if the project configuration has not been loaded.
pub fn assets(&self) -> Option<&Vec<String>> {
pub fn include(&self) -> Option<&Vec<String>> {
self.project
.as_ref()
.unwrap()
.as_ref()
.unwrap()
.assets
.deploy
.as_ref()
.and_then(|d| d.include.as_ref())
.or(self
.project
.as_ref()
.unwrap()
.as_ref()
.unwrap()
.assets
.as_ref())
}

/// # Panics
Expand Down
2 changes: 1 addition & 1 deletion cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3049,7 +3049,7 @@ impl Shuttle {
}

fn make_archive(&self, secrets_file: Option<PathBuf>, zip: bool) -> Result<Vec<u8>> {
let include_patterns = self.ctx.assets();
let include_patterns = self.ctx.include();

let working_directory = self.ctx.working_directory();

Expand Down

0 comments on commit 4820498

Please sign in to comment.