From f5017f603afab9821966032ea652cb3161051f17 Mon Sep 17 00:00:00 2001 From: "Eli W. Hunter" <42009212+elihunter173@users.noreply.github.com> Date: Sat, 23 Jan 2021 21:39:26 -0500 Subject: Add Stop{Signal,Timeout} to ContainerOptionsBuilder (#248) --- CHANGELOG.md | 2 +- src/builder.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 225dec7..3ba667b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,5 @@ # 0.7.0 - * async-await support [#229](https://github.com/softprops/shiplift/pull/229) * add multiple fields to `shiplift::rep::Version` [#212](https://github.com/softprops/shiplift/pull/212) * add `image_id` and `state` fields to `shiplift::rep::Container` [#213](https://github.com/softprops/shiplift/pull/213) @@ -15,6 +14,7 @@ * allow attaching to containers when connecting to Docker daemon via UNIX socket [#238](https://github.com/softprops/shiplift/pull/238) * support for uploading tar to container [#239](https://github.com/softprops/shiplift/pull/239) * fix registry authentication to use URL-safe base64 encoding [#245](https://github.com/softprops/shiplift/pull/245) +* add StopSignal and StopTimeout to ContainerOptionsBuilder [#248](https://github.com/softprops/shiplift/pull/248) # 0.6.0 diff --git a/src/builder.rs b/src/builder.rs index 1f6fc38..110abcc 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -8,6 +8,7 @@ use std::{ collections::{BTreeMap, HashMap}, hash::Hash, iter::{IntoIterator, Peekable}, + time::Duration, }; use url::form_urlencoded; @@ -931,6 +932,33 @@ impl ContainerOptionsBuilder { self } + /// Signal to stop a container as a string. Default is "SIGTERM". + pub fn stop_signal( + &mut self, + sig: &str, + ) -> &mut Self { + self.params.insert("StopSignal", json!(sig)); + self + } + + /// Signal to stop a container as an integer. Default is 15 (SIGTERM). + pub fn stop_signal_num( + &mut self, + sig: u64, + ) -> &mut Self { + self.params.insert("StopSignal", json!(sig)); + self + } + + /// Timeout to stop a container. Only seconds are counted. Default is 10s + pub fn stop_timeout( + &mut self, + timeout: Duration, + ) -> &mut Self { + self.params.insert("StopTimeout", json!(timeout.as_secs())); + self + } + pub fn userns_mode( &mut self, mode: &str, -- cgit v1.2.3