summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli W. Hunter <42009212+elihunter173@users.noreply.github.com>2021-01-23 21:39:26 -0500
committerGitHub <noreply@github.com>2021-01-23 21:39:26 -0500
commitf5017f603afab9821966032ea652cb3161051f17 (patch)
treeab9bf850eb507ed2fba39b66879c63066d52e3fa
parente5a9ed1aaff272beee99ad087e17fd9e6644285a (diff)
Add Stop{Signal,Timeout} to ContainerOptionsBuilder (#248)
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/builder.rs28
2 files changed, 29 insertions, 1 deletions
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,