diff options
author | Tom Fay <t.h.facer@gmail.com> | 2020-03-20 01:25:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-19 21:25:54 -0400 |
commit | a4cd2185976ad56b880d5a10374c4dee6d116e6a (patch) | |
tree | 70030b1042c4b6b29533b80eb853717052674d12 | |
parent | a8f67b15e1747d32411f17742f4d1d327d2a2803 (diff) |
Specify user when creating container (#220)
-rw-r--r-- | src/builder.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/builder.rs b/src/builder.rs index 0eecfa1..5541605 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -911,6 +911,14 @@ impl ContainerOptionsBuilder { self } + pub fn user( + &mut self, + user: &str, + ) -> &mut Self { + self.params.insert("User", json!(user)); + self + } + pub fn build(&self) -> ContainerOptions { ContainerOptions { name: self.name.clone(), @@ -1658,6 +1666,18 @@ mod tests { } #[test] + fn container_options_user() { + let options = ContainerOptionsBuilder::new("test_image") + .user("alice") + .build(); + + assert_eq!( + r#"{"HostConfig":{},"Image":"test_image","User":"alice"}"#, + options.serialize().unwrap() + ); + } + + #[test] fn container_options_host_config() { let options = ContainerOptionsBuilder::new("test_image") .network_mode("host") |