Skip to content

Commit

Permalink
feat: beta multi lang deployment models (#1820)
Browse files Browse the repository at this point in the history
* wip: python deployment models

* default build args

* fix: deploy cmd models

* remove python
  • Loading branch information
jonaro00 authored Jul 17, 2024
1 parent 11850df commit ec0df80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 7 additions & 6 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ use ignore::WalkBuilder;
use indicatif::ProgressBar;
use indoc::{formatdoc, printdoc};
use shuttle_common::models::deployment::{
BuildArgsBeta, BuildMetaBeta, DeploymentRequestBuildArchiveBeta, DeploymentRequestImageBeta,
BuildArgsBeta, BuildArgsRustBeta, BuildMetaBeta, DeploymentRequestBuildArchiveBeta,
DeploymentRequestImageBeta,
};
use shuttle_common::{
constants::{
Expand Down Expand Up @@ -1849,7 +1850,7 @@ impl Shuttle {
};

if self.beta {
let mut build_args = BuildArgsBeta::default();
let mut rust_build_args = BuildArgsRustBeta::default();

let metadata = async_cargo_metadata(manifest_path.as_path()).await?;
let packages = find_shuttle_packages(&metadata)?;
Expand All @@ -1858,20 +1859,20 @@ impl Shuttle {
.first()
.expect("at least one shuttle crate in the workspace");
let package_name = package.name.to_owned();
build_args.package_name = Some(package_name);
rust_build_args.package_name = Some(package_name);

// activate shuttle feature if present
let (no_default_features, features) = if package.features.contains_key("shuttle") {
(true, Some(vec!["shuttle".to_owned()]))
} else {
(false, None)
};
build_args.no_default_features = no_default_features;
build_args.features = features.map(|v| v.join(","));
rust_build_args.no_default_features = no_default_features;
rust_build_args.features = features.map(|v| v.join(","));

// TODO: determine which (one) binary to build

deployment_req_buildarch_beta.build_args = Some(build_args);
deployment_req_buildarch_beta.build_args = Some(BuildArgsBeta::Rust(rust_build_args));

// TODO: have all of the above be configurable in CLI and Shuttle.toml
}
Expand Down
12 changes: 10 additions & 2 deletions common/src/models/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,16 @@ pub struct DeploymentRequestBuildArchiveBeta {
pub build_meta: Option<BuildMetaBeta>,
}

#[derive(Deserialize, Serialize, Default)]
#[serde(tag = "type", content = "content")]
pub enum BuildArgsBeta {
Rust(BuildArgsRustBeta),
#[default]
Unknown,
}

#[derive(Deserialize, Serialize)]
pub struct BuildArgsBeta {
pub struct BuildArgsRustBeta {
/// Use the built in cargo chef setup for caching
pub cargo_chef: bool,
/// Build with the built in `cargo build` setup
Expand All @@ -329,7 +337,7 @@ pub struct BuildArgsBeta {
pub mold: bool,
}

impl Default for BuildArgsBeta {
impl Default for BuildArgsRustBeta {
fn default() -> Self {
Self {
cargo_chef: true,
Expand Down

0 comments on commit ec0df80

Please sign in to comment.