Skip to content

Commit

Permalink
Add ContainerOptionsBuilder::privileged() (softprops#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
imp authored and softprops committed Jan 21, 2019
1 parent 0ca553e commit 31a913b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,14 @@ impl ContainerOptionsBuilder {
self
}

pub fn privileged(
&mut self,
set: bool,
) -> &mut Self {
self.params.insert("HostConfig.Privileged", json!(set));
self
}

pub fn build(&self) -> ContainerOptions {
ContainerOptions {
name: self.name.clone(),
Expand Down Expand Up @@ -1393,10 +1401,11 @@ mod tests {
let options = ContainerOptionsBuilder::new("test_image")
.network_mode("host")
.auto_remove(true)
.privileged(true)
.build();

assert_eq!(
r#"{"HostConfig":{"AutoRemove":true,"NetworkMode":"host"},"Image":"test_image"}"#,
r#"{"HostConfig":{"AutoRemove":true,"NetworkMode":"host","Privileged":true},"Image":"test_image"}"#,
options.serialize().unwrap()
);
}
Expand Down

0 comments on commit 31a913b

Please sign in to comment.