(container_id: &str, command: &str)
| 113 | } |
| 114 | |
| 115 | pub fn exec(container_id: &str, command: &str) -> Result<Vec<u8>, String> { |
| 116 | // HACK: since wget and curl don't have any timeout by default, force it. |
| 117 | let command = if command.contains("wget ") { |
| 118 | debug!("patching wget command with timeout"); |
| 119 | command.replace("wget ", "wget --timeout 10 ") |
| 120 | } else if command.contains("curl ") { |
| 121 | debug!("patching curl command with timeout"); |
| 122 | command.replace("curl ", "curl --connect-timeout 10 ") |
| 123 | } else { |
| 124 | command.to_owned() |
| 125 | }; |
| 126 | |
| 127 | debug!( |
| 128 | "running command '{}' inside container '{}'", |
| 129 | &command, container_id |
| 130 | ); |
| 131 | |
| 132 | // create exec operation |
| 133 | let exec_id = create_exec(container_id, &command)?; |
| 134 | |
| 135 | // start exec operation by id |
| 136 | do_exec(&exec_id) |
| 137 | } |
no test coverage detected