fix: remove unwraps()
update_containers use an if let Some() instead of an unwrtap().to_owned()
This commit is contained in:
+5
-3
@@ -310,7 +310,7 @@ impl AppData {
|
||||
}
|
||||
|
||||
for i in containers.iter() {
|
||||
let id = i.id.as_ref().unwrap().to_owned();
|
||||
if let Some(id) = i.id.as_ref() {
|
||||
let mut name = i
|
||||
.names
|
||||
.as_ref()
|
||||
@@ -332,7 +332,7 @@ impl AppData {
|
||||
.trim()
|
||||
.to_owned();
|
||||
let image = i.image.as_ref().unwrap_or(&"".to_owned()).trim().to_owned();
|
||||
if let Some(current_container) = self.get_container_by_id(&id) {
|
||||
if let Some(current_container) = self.get_container_by_id(id) {
|
||||
if current_container.name != name {
|
||||
current_container.name = name
|
||||
};
|
||||
@@ -355,12 +355,14 @@ impl AppData {
|
||||
current_container.image = image
|
||||
};
|
||||
} else {
|
||||
let mut container = ContainerItem::new(id, status, image, state, name);
|
||||
let mut container =
|
||||
ContainerItem::new(id.to_owned(), status, image, state, name);
|
||||
container.logs.end();
|
||||
self.containers.items.push(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// update logs of a given container, based on index not id
|
||||
pub fn update_log_by_index(&mut self, output: Vec<String>, index: usize) {
|
||||
|
||||
Reference in New Issue
Block a user