mirror of
https://github.com/veeso/termscp.git
synced 2026-09-26 22:11:26 -07:00
feat: Pods and container explorer for Kube protocol (#281)
This commit is contained in:
@@ -111,7 +111,9 @@ impl FileTransferActivity {
|
||||
match &ft_params.params {
|
||||
ProtocolParams::Generic(params) => params.address.clone(),
|
||||
ProtocolParams::AwsS3(params) => params.bucket_name.clone(),
|
||||
ProtocolParams::Kube(params) => params.pod.clone(),
|
||||
ProtocolParams::Kube(params) => {
|
||||
params.namespace.clone().unwrap_or("default".to_string())
|
||||
}
|
||||
ProtocolParams::Smb(params) => params.address.clone(),
|
||||
ProtocolParams::WebDAV(params) => params.uri.clone(),
|
||||
}
|
||||
@@ -137,11 +139,9 @@ impl FileTransferActivity {
|
||||
format!("Connecting to {}…", params.bucket_name)
|
||||
}
|
||||
ProtocolParams::Kube(params) => {
|
||||
info!(
|
||||
"Client is not connected to remote; connecting to pod {}",
|
||||
params.pod,
|
||||
);
|
||||
format!("Connecting to {}…", params.pod)
|
||||
let namespace = params.namespace.as_deref().unwrap_or("default");
|
||||
info!("Client is not connected to remote; connecting to namespace {namespace}",);
|
||||
format!("Connecting to Kube namespace {namespace}…",)
|
||||
}
|
||||
ProtocolParams::Smb(params) => {
|
||||
info!(
|
||||
|
||||
@@ -57,7 +57,11 @@ impl FileTransferActivity {
|
||||
// Connect to remote
|
||||
match self.client.connect() {
|
||||
Ok(Welcome { banner, .. }) => {
|
||||
self.connected = true;
|
||||
self.connected = self.client.is_connected();
|
||||
if !self.connected {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(banner) = banner {
|
||||
// Log welcome
|
||||
self.log(
|
||||
@@ -68,6 +72,15 @@ impl FileTransferActivity {
|
||||
banner
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// Log welcome
|
||||
self.log(
|
||||
LogLevel::Info,
|
||||
format!(
|
||||
"Established connection with '{}'",
|
||||
self.get_remote_hostname()
|
||||
),
|
||||
);
|
||||
}
|
||||
// Try to change directory to entry directory
|
||||
let mut remote_chdir: Option<PathBuf> = None;
|
||||
@@ -111,16 +124,28 @@ impl FileTransferActivity {
|
||||
|
||||
/// Reload remote directory entries and update browser
|
||||
pub(super) fn reload_remote_dir(&mut self) {
|
||||
if !self.connected {
|
||||
return;
|
||||
}
|
||||
// Get current entries
|
||||
if let Ok(wrkdir) = self.client.pwd() {
|
||||
self.mount_blocking_wait("Loading remote directory...");
|
||||
|
||||
if self.remote_scan(wrkdir.as_path()).is_ok() {
|
||||
// Set wrkdir
|
||||
self.remote_mut().wrkdir = wrkdir;
|
||||
}
|
||||
let res = self.remote_scan(wrkdir.as_path());
|
||||
|
||||
self.umount_wait();
|
||||
|
||||
match res {
|
||||
Ok(_) => {
|
||||
self.remote_mut().wrkdir = wrkdir;
|
||||
}
|
||||
Err(err) => {
|
||||
self.log_and_alert(
|
||||
LogLevel::Error,
|
||||
format!("Could not scan current remote directory: {err}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,11 +155,21 @@ impl FileTransferActivity {
|
||||
|
||||
let wrkdir: PathBuf = self.host.pwd();
|
||||
|
||||
if self.local_scan(wrkdir.as_path()).is_ok() {
|
||||
self.local_mut().wrkdir = wrkdir;
|
||||
}
|
||||
let res = self.local_scan(wrkdir.as_path());
|
||||
|
||||
self.umount_wait();
|
||||
|
||||
match res {
|
||||
Ok(_) => {
|
||||
self.local_mut().wrkdir = wrkdir;
|
||||
}
|
||||
Err(err) => {
|
||||
self.log_and_alert(
|
||||
LogLevel::Error,
|
||||
format!("Could not scan current local directory: {err}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Scan current local directory
|
||||
@@ -146,13 +181,7 @@ impl FileTransferActivity {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Err(err) => {
|
||||
self.log_and_alert(
|
||||
LogLevel::Error,
|
||||
format!("Could not scan current directory: {err}"),
|
||||
);
|
||||
Err(err)
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,13 +193,7 @@ impl FileTransferActivity {
|
||||
self.remote_mut().set_files(files);
|
||||
Ok(())
|
||||
}
|
||||
Err(err) => {
|
||||
self.log_and_alert(
|
||||
LogLevel::Error,
|
||||
format!("Could not scan current directory: {err}"),
|
||||
);
|
||||
Err(err)
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ impl FileTransferActivity {
|
||||
self.refresh_remote_status_bar();
|
||||
// Update components
|
||||
self.update_local_filelist();
|
||||
self.update_remote_filelist();
|
||||
// self.update_remote_filelist();
|
||||
// Global listener
|
||||
self.mount_global_listener();
|
||||
// Give focus to local explorer
|
||||
|
||||
Reference in New Issue
Block a user