From 8ea7da5537978a1ef7613eadd406c713af03d9fd Mon Sep 17 00:00:00 2001 From: Deepu Date: Mon, 19 Aug 2024 14:28:53 +0200 Subject: [PATCH] lint fix --- Cargo.lock | 16 ++++++++++++---- src/app/contexts.rs | 4 ++-- src/app/dynamic.rs | 16 ++++++++-------- src/app/ingress.rs | 5 +---- src/app/mod.rs | 17 ++++++++--------- src/event/events.rs | 5 ----- src/handlers/mod.rs | 3 ++- src/network/mod.rs | 10 +++++----- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 599363a..de955f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1258,6 +1258,12 @@ dependencies = [ "memoffset", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" version = "0.2.17" @@ -2222,12 +2228,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -2242,10 +2249,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] diff --git a/src/app/contexts.rs b/src/app/contexts.rs index 44a0b13..86ce1b3 100644 --- a/src/app/contexts.rs +++ b/src/app/contexts.rs @@ -23,7 +23,7 @@ pub struct KubeContext { pub name: String, pub cluster: String, pub user: String, - pub namespace: Option, + // pub namespace: Option, pub is_active: bool, } @@ -35,7 +35,7 @@ impl KubeContext { name: ctx.name.clone(), cluster: context.cluster.clone(), user: context.user.clone(), - namespace: context.namespace.clone(), + // namespace: context.namespace.clone(), is_active, } } diff --git a/src/app/dynamic.rs b/src/app/dynamic.rs index 0884a6b..0d3f875 100644 --- a/src/app/dynamic.rs +++ b/src/app/dynamic.rs @@ -28,10 +28,10 @@ use crate::{ #[derive(Clone, Debug)] pub struct KubeDynamicKind { - pub name: String, - pub group: String, - pub version: String, - pub api_version: String, + // pub name: String, + // pub group: String, + // pub version: String, + // pub api_version: String, pub kind: String, pub scope: Scope, pub api_resource: ApiResource, @@ -41,10 +41,10 @@ impl KubeDynamicKind { pub fn new(ar: ApiResource, scope: Scope) -> Self { KubeDynamicKind { api_resource: ar.clone(), - name: ar.plural, - group: ar.group, - version: ar.version, - api_version: ar.api_version, + // name: ar.plural, + // group: ar.group, + // version: ar.version, + // api_version: ar.api_version, kind: ar.kind, scope, } diff --git a/src/app/ingress.rs b/src/app/ingress.rs index 056606c..c870c1b 100644 --- a/src/app/ingress.rs +++ b/src/app/ingress.rs @@ -60,10 +60,7 @@ impl From for KubeIngress { Some(n) => n.clone(), None => UNKNOWN.into(), }; - let paths = match rules { - Some(r) => r, - None => String::default(), - }; + let paths = rules.unwrap_or_default(); Self { name, namespace, diff --git a/src/app/mod.rs b/src/app/mod.rs index 24c3fd0..307bc35 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -209,12 +209,12 @@ pub struct App { pub tick_until_poll: u64, pub tick_count: u64, pub enhanced_graphics: bool, - pub table_cols: u16, + // pub table_cols: u16, + // pub dialog: Option, + // pub confirm: bool, pub size: Rect, pub api_error: String, - pub dialog: Option, pub app_input: AppInput, - pub confirm: bool, pub light_theme: bool, pub refresh: bool, pub log_auto_scroll: bool, @@ -422,15 +422,15 @@ impl Default for App { tick_until_poll: 0, tick_count: 0, enhanced_graphics: false, - table_cols: 0, + // table_cols: 0, + // dialog: None, + // confirm: false, size: Rect::default(), api_error: String::new(), - dialog: None, app_input: AppInput { input: Input::default(), input_mode: InputMode::Normal, }, - confirm: false, light_theme: false, refresh: true, log_auto_scroll: true, @@ -755,10 +755,9 @@ mod test_utils { use super::models::KubeResource; - pub fn convert_resource_from_file(filename: &str) -> (Vec, Vec) + pub fn convert_resource_from_file(filename: &str) -> (Vec, Vec) where - K: Clone + DeserializeOwned + fmt::Debug, - K: Resource, + K: Serialize + Resource + Clone + DeserializeOwned + fmt::Debug, T: KubeResource + From, { let res_list = load_resource_from_file(filename); diff --git a/src/event/events.rs b/src/event/events.rs index a9fa956..8f00543 100644 --- a/src/event/events.rs +++ b/src/event/events.rs @@ -7,12 +7,9 @@ use std::{ use crossterm::event::{self, Event as CEvent, KeyEvent, MouseEvent}; -use super::Key; - #[derive(Debug, Clone, Copy)] /// Configuration for event handling. pub struct EventConfig { - pub exit_key: Key, /// The tick rate at which the application will sent an tick event. pub tick_rate: Duration, } @@ -20,7 +17,6 @@ pub struct EventConfig { impl Default for EventConfig { fn default() -> EventConfig { EventConfig { - exit_key: Key::Ctrl('c'), tick_rate: Duration::from_millis(250), } } @@ -48,7 +44,6 @@ impl Events { pub fn new(tick_rate: u64) -> Events { Events::with_config(EventConfig { tick_rate: Duration::from_millis(tick_rate), - ..EventConfig::default() }) } diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 0be1ac6..248ca03 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -739,9 +739,10 @@ async fn handle_block_scroll(app: &mut App, up: bool, is_mouse: bool, page: bool } fn copy_to_clipboard(content: String, app: &mut App) { + use std::thread; + use anyhow::anyhow; use copypasta::{ClipboardContext, ClipboardProvider}; - use std::thread; match ClipboardContext::new() { Ok(mut ctx) => match ctx.set_contents(content) { diff --git a/src/network/mod.rs b/src/network/mod.rs index eb85a49..2898e44 100644 --- a/src/network/mod.rs +++ b/src/network/mod.rs @@ -269,7 +269,7 @@ impl<'a> Network<'a> { } /// calls the kubernetes API to list the given resource for either selected namespace or all namespaces - pub async fn get_namespaced_resources(&self, map_fn: F) -> Vec + pub async fn get_namespaced_resources(&self, map_fn: F) -> Vec where ::DynamicType: Default, K: kube::Resource, @@ -294,10 +294,10 @@ impl<'a> Network<'a> { } /// calls the kubernetes API to list the given resource for all namespaces - pub async fn get_resources(&self, map_fn: F) -> Vec + pub async fn get_resources(&self, map_fn: F) -> Vec where ::DynamicType: Default, - K: Clone + DeserializeOwned + fmt::Debug, + K: ApiResource + Clone + DeserializeOwned + fmt::Debug, F: Fn(K) -> T, { let api: Api = Api::all(self.client.clone()); @@ -317,10 +317,10 @@ impl<'a> Network<'a> { } } - pub async fn get_namespaced_api(&self) -> Api + pub async fn get_namespaced_api(&self) -> Api where ::DynamicType: Default, - K: kube::Resource, + K: ApiResource + kube::Resource, { let app = self.app.lock().await; match &app.data.selected.ns {