@@ -8,6 +8,7 @@ use std::net;
88
99use crate :: docker_run:: docker;
1010use crate :: docker_run:: unix_stream;
11+ use crate :: docker_run:: debug;
1112
1213
1314#[ derive( Debug ) ]
@@ -26,7 +27,7 @@ pub struct Limits {
2627
2728
2829
29- pub fn run < T : Serialize > ( stream_config : unix_stream:: Config , run_request : RunRequest < T > ) -> Result < Map < String , Value > , Error > {
30+ pub fn run < T : Serialize > ( stream_config : unix_stream:: Config , run_request : RunRequest < T > , debug : debug :: Config ) -> Result < Map < String , Value > , Error > {
3031 let container_response = unix_stream:: with_stream ( & stream_config, Error :: UnixStream , |stream| {
3132 docker:: create_container ( stream, & run_request. container_config )
3233 . map_err ( Error :: CreateContainer )
@@ -36,17 +37,19 @@ pub fn run<T: Serialize>(stream_config: unix_stream::Config, run_request: RunReq
3637
3738 let result = run_with_container ( & stream_config, run_request, & container_id) ;
3839
39- let _ = unix_stream:: with_stream ( & stream_config, Error :: UnixStream , |stream| {
40- match docker:: remove_container ( stream, & container_id) {
41- Ok ( _) => { }
40+ if !debug. keep_container {
41+ let _ = unix_stream:: with_stream ( & stream_config, Error :: UnixStream , |stream| {
42+ match docker:: remove_container ( stream, & container_id) {
43+ Ok ( _) => { }
4244
43- Err ( err) => {
44- log:: error!( "Failed to remove container: {}" , err) ;
45+ Err ( err) => {
46+ log:: error!( "Failed to remove container: {}" , err) ;
47+ }
4548 }
46- }
4749
48- Ok ( ( ) )
49- } ) ;
50+ Ok ( ( ) )
51+ } ) ;
52+ }
5053
5154 result
5255}
0 commit comments