fix: address clippy warnings
Some checks failed
Test / frontend-tests (pull_request) Successful in 1m26s
Test / frontend-typecheck (pull_request) Successful in 1m34s
PR Review Automation / review (pull_request) Successful in 3m33s
Test / rust-fmt-check (pull_request) Failing after 10m30s
Test / rust-clippy (pull_request) Successful in 12m7s
Test / rust-tests (pull_request) Successful in 13m54s

- Remove unused imports
- Use PortForwardSessionConfig struct to reduce function arguments
This commit is contained in:
Shaun Arman 2026-06-06 13:47:51 -05:00
parent 1d0689556d
commit 05ec2e4fbb
2 changed files with 32 additions and 29 deletions

View File

@ -1,4 +1,5 @@
use crate::kube::ClusterClient; use crate::kube::ClusterClient;
use crate::kube::portforward::PortForwardSessionConfig;
use crate::state::AppState; use crate::state::AppState;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_yaml::Value; use serde_yaml::Value;
@ -154,16 +155,16 @@ pub async fn start_port_forward(
let cluster_name = cluster.name.clone(); let cluster_name = cluster.name.clone();
let _kubeconfig_content = cluster.kubeconfig_content.clone(); let _kubeconfig_content = cluster.kubeconfig_content.clone();
let session = crate::kube::PortForwardSession::new( let session = crate::kube::PortForwardSession::new(PortForwardSessionConfig {
session_id.clone(), id: session_id.clone(),
request.cluster_id.clone(), cluster_id: request.cluster_id.clone(),
cluster_name, cluster_name,
request.namespace.clone(), namespace: request.namespace.clone(),
request.pod.clone(), pod: request.pod.clone(),
None, container: None,
vec![request.container_port], ports: vec![request.container_port],
vec![0], local_ports: vec![0],
); });
{ {
let mut port_forwards = state.port_forwards.lock().await; let mut port_forwards = state.port_forwards.lock().await;

View File

@ -1,4 +1,3 @@
use std::process::{Child, Command, Stdio};
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc; use std::sync::Arc;
@ -12,7 +11,7 @@ pub struct PortForwardSession {
pub ports: Vec<u16>, pub ports: Vec<u16>,
pub local_ports: Vec<u16>, pub local_ports: Vec<u16>,
pub status: PortForwardStatus, pub status: PortForwardStatus,
pub kubectl_child: Option<Arc<std::sync::Mutex<Child>>>, pub kubectl_child: Option<Arc<std::sync::Mutex<std::process::Child>>>,
pub is_stopped: Arc<AtomicBool>, pub is_stopped: Arc<AtomicBool>,
} }
@ -22,26 +21,29 @@ pub enum PortForwardStatus {
Error(String), Error(String),
} }
#[derive(Debug, Clone)]
pub struct PortForwardSessionConfig {
pub id: String,
pub cluster_id: String,
pub cluster_name: String,
pub namespace: String,
pub pod: String,
pub container: Option<String>,
pub ports: Vec<u16>,
pub local_ports: Vec<u16>,
}
impl PortForwardSession { impl PortForwardSession {
pub fn new( pub fn new(config: PortForwardSessionConfig) -> Self {
id: String,
cluster_id: String,
cluster_name: String,
namespace: String,
pod: String,
container: Option<String>,
ports: Vec<u16>,
local_ports: Vec<u16>,
) -> Self {
Self { Self {
id, id: config.id,
cluster_id, cluster_id: config.cluster_id,
cluster_name, cluster_name: config.cluster_name,
namespace, namespace: config.namespace,
pod, pod: config.pod,
container, container: config.container,
ports, ports: config.ports,
local_ports, local_ports: config.local_ports,
status: PortForwardStatus::Active, status: PortForwardStatus::Active,
kubectl_child: None, kubectl_child: None,
is_stopped: Arc::new(AtomicBool::new(false)), is_stopped: Arc::new(AtomicBool::new(false)),