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
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:
parent
1d0689556d
commit
05ec2e4fbb
@ -1,4 +1,5 @@
|
||||
use crate::kube::ClusterClient;
|
||||
use crate::kube::portforward::PortForwardSessionConfig;
|
||||
use crate::state::AppState;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_yaml::Value;
|
||||
@ -154,16 +155,16 @@ pub async fn start_port_forward(
|
||||
let cluster_name = cluster.name.clone();
|
||||
let _kubeconfig_content = cluster.kubeconfig_content.clone();
|
||||
|
||||
let session = crate::kube::PortForwardSession::new(
|
||||
session_id.clone(),
|
||||
request.cluster_id.clone(),
|
||||
let session = crate::kube::PortForwardSession::new(PortForwardSessionConfig {
|
||||
id: session_id.clone(),
|
||||
cluster_id: request.cluster_id.clone(),
|
||||
cluster_name,
|
||||
request.namespace.clone(),
|
||||
request.pod.clone(),
|
||||
None,
|
||||
vec![request.container_port],
|
||||
vec![0],
|
||||
);
|
||||
namespace: request.namespace.clone(),
|
||||
pod: request.pod.clone(),
|
||||
container: None,
|
||||
ports: vec![request.container_port],
|
||||
local_ports: vec![0],
|
||||
});
|
||||
|
||||
{
|
||||
let mut port_forwards = state.port_forwards.lock().await;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
use std::process::{Child, Command, Stdio};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
@ -12,7 +11,7 @@ pub struct PortForwardSession {
|
||||
pub ports: Vec<u16>,
|
||||
pub local_ports: Vec<u16>,
|
||||
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>,
|
||||
}
|
||||
|
||||
@ -22,26 +21,29 @@ pub enum PortForwardStatus {
|
||||
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 {
|
||||
pub fn new(
|
||||
id: String,
|
||||
cluster_id: String,
|
||||
cluster_name: String,
|
||||
namespace: String,
|
||||
pod: String,
|
||||
container: Option<String>,
|
||||
ports: Vec<u16>,
|
||||
local_ports: Vec<u16>,
|
||||
) -> Self {
|
||||
pub fn new(config: PortForwardSessionConfig) -> Self {
|
||||
Self {
|
||||
id,
|
||||
cluster_id,
|
||||
cluster_name,
|
||||
namespace,
|
||||
pod,
|
||||
container,
|
||||
ports,
|
||||
local_ports,
|
||||
id: config.id,
|
||||
cluster_id: config.cluster_id,
|
||||
cluster_name: config.cluster_name,
|
||||
namespace: config.namespace,
|
||||
pod: config.pod,
|
||||
container: config.container,
|
||||
ports: config.ports,
|
||||
local_ports: config.local_ports,
|
||||
status: PortForwardStatus::Active,
|
||||
kubectl_child: None,
|
||||
is_stopped: Arc::new(AtomicBool::new(false)),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user