Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Let container device be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
seowalex committed Mar 31, 2023
1 parent d7d2f76 commit 7dc4535
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 37 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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.1.7] - 2023-03-31

### Fixed

- Let container device be optional.

## [0.1.6] - 2023-02-15

### Fixed
Expand Down
44 changes: 22 additions & 22 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "haddock"
version = "0.1.6"
version = "0.1.7"
edition = "2021"
description = "Docker Compose for Podman"
repository = "https://github.com/seowalex/haddock"
Expand All @@ -18,7 +18,7 @@ console = "0.15.5"
dotenvy = "0.15.7"
fastrand = "1.9.0"
figment = { version = "0.10.8", features = ["env"] }
futures = "0.3.27"
futures = "0.3.28"
heck = "0.4.1"
hex = "0.4.3"
humantime = "2.1.0"
Expand Down
24 changes: 11 additions & 13 deletions src/compose/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ pub(crate) struct Resource {
pub(crate) struct Device {
#[serde_as(as = "AbsPathBuf")]
pub(crate) source: PathBuf,
pub(crate) target: PathBuf,
pub(crate) target: Option<PathBuf>,
pub(crate) permissions: Option<String>,
}

Expand All @@ -724,16 +724,17 @@ impl Hash for Device {

impl Display for Device {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let mut device = vec![self.source.to_string_lossy().to_string()];

if let Some(target) = &self.target {
device.push(target.to_string_lossy().to_string());
}

if let Some(permissions) = &self.permissions {
write!(
f,
"{}:{}:{permissions}",
self.source.display(),
self.target.display()
)
} else {
write!(f, "{}:{}", self.source.display(), self.target.display())
device.push(permissions.clone());
}

write!(f, "{}", device.join(":"))
}
}

Expand Down Expand Up @@ -1295,10 +1296,7 @@ serde_conv!(

Ok(Device {
source: Path::new(parts.next().unwrap()).absolutize()?.to_path_buf(),
target: parts
.next()
.map(PathBuf::from)
.ok_or_else(|| anyhow!("too little colons"))?,
target: parts.next().map(PathBuf::from),
permissions: parts.next().map(ToString::to_string),
})
}
Expand Down

0 comments on commit 7dc4535

Please sign in to comment.