Skip to content

Commit

Permalink
Merge pull request #94 from Malax/schneems/add-default-to-process-types
Browse files Browse the repository at this point in the history
API 0.6: Support setting the default process type in `launch.toml`
  • Loading branch information
schneems authored Oct 28, 2021
2 parents 54bfde0 + f4c62c5 commit 4121fbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Add support for `default` key in `launch.toml` in `Process` struct
- Support the new `buildpack.toml` fields `description`, `keywords` and `licenses`
- Set a minumim required Rust version of 1.56 and switch to the 2021 Rust edition
- Stack id in `buildpack.toml` can now be `*` indicating "any" stack
Expand Down
7 changes: 6 additions & 1 deletion src/data/launch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::data::bom;
use crate::data::defaults;
use lazy_static::lazy_static;
use regex::Regex;
use serde::{Deserialize, Serialize};
Expand All @@ -24,7 +25,7 @@ pub struct Launch {
/// use libcnb::data::launch;
/// let mut launch_toml = launch::Launch::new();
/// let web = launch::Process::new("web", "bundle", vec!["exec", "ruby", "app.rb"],
/// false).unwrap();
/// false, false).unwrap();
///
/// launch_toml.processes.push(web);
/// assert!(toml::to_string(&launch_toml).is_ok());
Expand Down Expand Up @@ -63,6 +64,8 @@ pub struct Process {
pub command: String,
pub args: Vec<String>,
pub direct: bool,
#[serde(default = "defaults::r#false")]
pub default: bool,
}

impl Process {
Expand All @@ -71,12 +74,14 @@ impl Process {
command: impl Into<String>,
args: impl IntoIterator<Item = impl Into<String>>,
direct: bool,
default: bool,
) -> Result<Self, ProcessTypeError> {
Ok(Process {
r#type: ProcessType::from_str(r#type.as_ref())?,
command: command.into(),
args: args.into_iter().map(|i| i.into()).collect(),
direct,
default,
})
}
}
Expand Down

0 comments on commit 4121fbf

Please sign in to comment.