summaryrefslogtreecommitdiffstats
path: root/examples/logs.rs
diff options
context:
space:
mode:
authorWojciech Kępka <46892771+wojciechkepka@users.noreply.github.com>2021-02-09 01:22:26 +0100
committerGitHub <noreply@github.com>2021-02-08 19:22:26 -0500
commit5af822c5691a772cad36bd9a69e94419b03d4511 (patch)
tree761ebc2ac10608a8772d8f7085596ee2ee838b37 /examples/logs.rs
parent4e3f69c34a177697af940849fced1a284fc09449 (diff)
Add services api (#263)
* Add initial Services models * Add initial Services controllers * Add ServicesListOptions * Rename ServicesList -> ServiceList * Fix some optional fields on ServiceRep * Add Service::inspect * Add Service::delete * Add Service::logs * Rename example logs -> containerlogs * Add ServiceOptions, ServiceCreateInfo, fix typo * Add a way to pass headers to request, add Payload and Headers for easier types * Add Service::create * Add examples * Fix fmt * Fix example
Diffstat (limited to 'examples/logs.rs')
-rw-r--r--examples/logs.rs32
1 files changed, 0 insertions, 32 deletions
diff --git a/examples/logs.rs b/examples/logs.rs
deleted file mode 100644
index eb3bdb5..0000000
--- a/examples/logs.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-use futures::StreamExt;
-use shiplift::{tty::TtyChunk, Docker, LogsOptions};
-use std::env;
-
-#[tokio::main]
-async fn main() {
- let docker = Docker::new();
- let id = env::args()
- .nth(1)
- .expect("You need to specify a container id");
-
- let containers = docker.containers();
-
- let mut logs_stream = containers
- .get(&id)
- .logs(&LogsOptions::builder().stdout(true).stderr(true).build());
-
- while let Some(log_result) = logs_stream.next().await {
- match log_result {
- Ok(chunk) => print_chunk(chunk),
- Err(e) => eprintln!("Error: {}", e),
- }
- }
-}
-
-fn print_chunk(chunk: TtyChunk) {
- match chunk {
- TtyChunk::StdOut(bytes) => println!("Stdout: {}", std::str::from_utf8(&bytes).unwrap()),
- TtyChunk::StdErr(bytes) => eprintln!("Stdout: {}", std::str::from_utf8(&bytes).unwrap()),
- TtyChunk::StdIn(_) => unreachable!(),
- }
-}