chore: merge release-v0.1.1 into main

This commit is contained in:
Jack Wills
2022-07-23 13:52:01 +00:00
6 changed files with 68 additions and 29 deletions
+6 -4
View File
@@ -1,11 +1,13 @@
### 2022-07-23
### Chores
+ dependencies updated, [cf7e02dde94f69832a2e485b99785afc66a5bc15]
+ update Cargo.toml, in preparation for crates.io publishing, [fdc6898e20c41415f03e310d7b84af4b6c39ab62]
### Features
+ Enable sorting of containers by each, and every, heading. Either via keyboard or mouse, closes [#3], [a6c296f2cde56cf241bcd696cab8bd477270e5f4]
+ Spawn & track docker information update requests, multiple identical requests cannot be executed, [740c059b276f35acd1cb03f1030134646bf8a07d]
### Docs
+ added cargo install instructions, [c774b10d557b10885b9d3a0b3612330a8ecb1cd5]
### Fixes
+ use SpawnId for docker hashmap JoinHandle mapping, [1ae95d58c3302a95d5a0a2f0b61b126c72b6e166]
see <a href='https://github.com/mrjackwills/oxker/blob/main/CHANGELOG.md'>CHANGELOG.md</a> for more details
Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 KiB

After

Width:  |  Height:  |  Size: 434 KiB

+12
View File
@@ -1,3 +1,15 @@
# <a href='https://github.com/mrjackwills/oxker/releases/tag/v0.1.1'>v0.1.1</a>
### 2022-07-23
### Chores
+ update Cargo.toml, in preparation for crates.io publishing, [fdc6898e](https://github.com/mrjackwills/oxker/commit/fdc6898e20c41415f03e310d7b84af4b6c39ab62),
### Docs
+ added cargo install instructions, [c774b10d](https://github.com/mrjackwills/oxker/commit/c774b10d557b10885b9d3a0b3612330a8ecb1cd5),
### Fixes
+ use SpawnId for docker hashmap JoinHandle mapping, [1ae95d58](https://github.com/mrjackwills/oxker/commit/1ae95d58c3302a95d5a0a2f0b61b126c72b6e166),
# <a href='https://github.com/mrjackwills/oxker/releases/tag/v0.1.0'>v0.1.0</a>
### 2022-07-23
+5 -1
View File
@@ -1,12 +1,15 @@
[package]
name = "oxker"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["Jack Wills <email@mrjackwills.com>"]
description = "a simple tui to view & control docker containers"
repository = "https://github.com/mrjackwills/oxker"
homepage = "https://github.com/mrjackwills/oxker"
license = "MIT"
readme = "README.md"
keywords = ["docker", "tui", "tui-rs", "tokio"]
categories = ["command-line-utilities"]
[dependencies]
anyhow = "1.0"
@@ -16,6 +19,7 @@ clap={version="3.2", features = ["derive", "unicode"] }
crossterm = "0.24"
futures-util = "0.3"
parking_lot = {version= "0.12"}
reqwest = "0.11.11"
tokio = {version = "1.20", features=["full"]}
tracing = "0.1"
tracing-subscriber = "0.3"
+8 -3
View File
@@ -23,9 +23,14 @@
## Download & install
See <a href="https://github.com/mrjackwills/oxker/releases" target='_blank' rel='noopener noreferrer'>releases</a>
Now published on <a href='https://www.crates.io/crates/oxker' target='_blank' rel='noopener noreferrer'>crates.io</a>, so if you have cargo installed, simply run
download & install (x86_64 one liner)
``` cargo install oxker```
else see the <a href="https://github.com/mrjackwills/oxker/releases/latest" target='_blank' rel='noopener noreferrer'>pre-built binaries</a>
or, download & install (x86_64 one liner)
```bash
wget https://www.github.com/mrjackwills/oxker/releases/latest/download/oxker_linux_x86_64.tar.gz &&
@@ -51,7 +56,7 @@ In application controls
| ```( q )``` | to quit at any time |
available command line arguments
Available command line arguments
| argument|result|
|--|--|
|```-d [number > 0]```| set the minimum update interval for docker information, in ms, defaults to 1000 (1 second) |
+36 -20
View File
@@ -6,6 +6,7 @@ use futures_util::StreamExt;
use parking_lot::Mutex;
use std::{
collections::HashMap,
fmt,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
@@ -22,6 +23,22 @@ use crate::{
mod message;
pub use message::DockerMessage;
#[derive(Debug, Hash, Clone, PartialEq, Eq)]
enum SpawnId {
Stats(String),
Log(String),
}
impl fmt::Display for SpawnId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let disp = match self {
Self::Stats(id) => format!("stats::{id}"),
Self::Log(id) => format!("logs::{id}"),
};
write!(f, "{}", disp)
}
}
pub struct DockerData {
app_data: Arc<Mutex<AppData>>,
docker: Arc<Docker>,
@@ -29,7 +46,7 @@ pub struct DockerData {
initialised: bool,
is_running: Arc<AtomicBool>,
receiver: Receiver<DockerMessage>,
spawns: Arc<Mutex<HashMap<String, JoinHandle<()>>>>,
spawns: Arc<Mutex<HashMap<SpawnId, JoinHandle<()>>>>,
timestamps: bool,
}
@@ -69,7 +86,7 @@ impl DockerData {
id: String,
app_data: Arc<Mutex<AppData>>,
is_running: bool,
spawns: Arc<Mutex<HashMap<String, JoinHandle<()>>>>,
spawns: Arc<Mutex<HashMap<SpawnId, JoinHandle<()>>>>,
) {
let mut stream = docker
.stats(
@@ -117,7 +134,8 @@ impl DockerData {
.lock()
.update_stats(id.clone(), None, None, mem_limit, rx, tx);
}
spawns.lock().remove(&id);
let key = SpawnId::Stats(id.to_owned());
spawns.lock().remove(&key);
}
}
@@ -130,7 +148,8 @@ impl DockerData {
let is_running = *is_running;
let id = id.to_owned();
let spawn_contains_id = spawns.lock().contains_key(&id);
let key = SpawnId::Stats(id.to_owned());
let spawn_contains_id = spawns.lock().contains_key(&key);
let s = tokio::spawn(Self::update_container_stat(
docker,
id.to_owned(),
@@ -139,7 +158,7 @@ impl DockerData {
spawns,
));
if !spawn_contains_id {
self.spawns.lock().insert(id, s);
self.spawns.lock().insert(key, s);
}
}
}
@@ -190,7 +209,7 @@ impl DockerData {
timestamps: bool,
since: i64,
app_data: Arc<Mutex<AppData>>,
spawns: Arc<Mutex<HashMap<String, JoinHandle<()>>>>,
spawns: Arc<Mutex<HashMap<SpawnId, JoinHandle<()>>>>,
) {
let options = Some(LogsOptions::<String> {
stdout: true,
@@ -211,7 +230,8 @@ impl DockerData {
}
}
}
spawns.lock().remove(&id);
let key = SpawnId::Log(id.to_owned());
spawns.lock().remove(&key);
app_data.lock().update_log_by_id(output, id.to_owned());
}
@@ -223,12 +243,12 @@ impl DockerData {
let id = id.to_owned();
let app_data = Arc::clone(&self.app_data);
let spawns = Arc::clone(&self.spawns);
self.spawns.lock().insert(
id.to_owned(),
tokio::spawn(Self::update_log(
let key = SpawnId::Log(id.to_owned());
let s = tokio::spawn(Self::update_log(
docker, id, timestamps, 0, app_data, spawns,
)),
);
));
self.spawns.lock().insert(key, s);
}
}
@@ -238,7 +258,8 @@ impl DockerData {
if let Some(index) = optional_index {
let id = self.app_data.lock().containers.items[index].id.to_owned();
let running = self.spawns.lock().contains_key(&id);
let key = SpawnId::Log(id.to_owned());
let running = self.spawns.lock().contains_key(&key);
if !running {
let since = self.app_data.lock().containers.items[index].last_updated as i64;
@@ -248,14 +269,9 @@ impl DockerData {
let app_data = Arc::clone(&self.app_data);
let spawns = Arc::clone(&self.spawns);
let s = tokio::spawn(Self::update_log(
docker,
id.to_owned(),
timestamps,
since,
app_data,
spawns,
docker, id, timestamps, since, app_data, spawns,
));
self.spawns.lock().insert(id, s);
self.spawns.lock().insert(key, s);
}
};