Skip to content

Commit

Permalink
Allow mount_paths to be absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
stepchowfun committed Jul 11, 2019
1 parent eae6c29 commit 8e5793e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.29.0] - 2019-07-11

### Changed
- `mount_paths` are now allowed to be absolute. This is to support mounting the Docker IPC socket (usually located at `/var/run/docker.sock`) in the container for running Docker commands in tasks.

## [0.28.0] - 2019-06-30

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "toast"
version = "0.28.0"
version = "0.29.0"
authors = ["Stephan Boyer <stephan@stephanboyer.com>"]
description = "Containerize your development and continuous integration environments."
license = "MIT"
Expand Down
24 changes: 5 additions & 19 deletions src/toastfile.rs
Expand Up @@ -41,7 +41,8 @@ pub struct Task {
#[serde(default)]
pub output_paths: Vec<PathBuf>,

// Must be relative [ref:mount_paths_relative]
// Can be relative or absolute (absolute paths are allowed in order to support mounting the
// Docker socket, which is usually located at `/var/run/docker.sock`)
// Must not contain `,` [ref:mount_paths_no_commas]
// Must be empty if `cache` is enabled [ref:mount_paths_nand_cache]
#[serde(default)]
Expand Down Expand Up @@ -347,19 +348,6 @@ fn check_task(name: &str, task: &Task) -> Result<(), Failure> {

// Check `mount_paths`.
for path in &task.mount_paths {
// Check that the path is relative. [tag:mount_paths_relative]
if path.is_absolute() {
return Err(Failure::User(
format!(
"Task {} has an absolute {}: {}.",
name.code_str(),
"mount_path".code_str(),
path.to_string_lossy().code_str()
),
None,
));
}

// Check that the path doesn't contain any commas. [tag:mount_paths_no_commas]
if path.to_string_lossy().contains(',') {
return Err(Failure::User(
Expand Down Expand Up @@ -1135,7 +1123,7 @@ tasks:
let task = Task {
description: None,
dependencies: vec![],
cache: true,
cache: false,
environment: HashMap::new(),
input_paths: vec![],
output_paths: vec![Path::new("/bar").to_owned()],
Expand All @@ -1157,7 +1145,7 @@ tasks:
let task = Task {
description: None,
dependencies: vec![],
cache: true,
cache: false,
environment: HashMap::new(),
input_paths: vec![],
output_paths: vec![],
Expand All @@ -1169,9 +1157,7 @@ tasks:
command: String::new(),
};

let result = check_task("foo", &task);
assert!(result.is_err());
assert!(result.unwrap_err().to_string().contains("/bar"));
assert!(check_task("foo", &task).is_ok());
}

#[test]
Expand Down

0 comments on commit 8e5793e

Please sign in to comment.