mirror of
https://github.com/veeso/termscp.git
synced 2026-09-28 06:51:20 -07:00
feat(gcs): add Google Cloud Storage support (#443)
* feat(gcs): add Google Cloud Storage support Closes #436 * fix: honor configured protocol and finalization errors * ci: remove TruffleHog checks
This commit is contained in:
@@ -9,6 +9,7 @@ pub(super) fn default_port_for_protocol(protocol: FileTransferProtocol) -> u16 {
|
||||
match protocol {
|
||||
FileTransferProtocol::Ftp(_) => 21,
|
||||
FileTransferProtocol::Scp | FileTransferProtocol::Sftp => 22,
|
||||
FileTransferProtocol::GoogleCloudStorage => 22,
|
||||
_ => 22,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,12 +11,14 @@ use super::credentials::{optional_capture, required_capture};
|
||||
use super::ports::{default_port_for_protocol, parse_port};
|
||||
use super::protocol::parse_remote_opt_protocol;
|
||||
use super::{
|
||||
REMOTE_GENERIC_OPT_REGEX, REMOTE_KUBE_OPT_REGEX, REMOTE_S3_OPT_REGEX, REMOTE_WEBDAV_OPT_REGEX,
|
||||
REMOTE_GCS_OPT_REGEX, REMOTE_GENERIC_OPT_REGEX, REMOTE_KUBE_OPT_REGEX, REMOTE_S3_OPT_REGEX,
|
||||
REMOTE_WEBDAV_OPT_REGEX,
|
||||
};
|
||||
#[cfg(smb)]
|
||||
use crate::filetransfer::params::SmbParams;
|
||||
use crate::filetransfer::params::{
|
||||
AwsS3Params, GenericProtocolParams, KubeProtocolParams, ProtocolParams, WebDAVProtocolParams,
|
||||
AwsS3Params, GenericProtocolParams, GoogleCloudStorageParams, KubeProtocolParams,
|
||||
ProtocolParams, WebDAVProtocolParams,
|
||||
};
|
||||
use crate::filetransfer::{FileTransferParams, FileTransferProtocol};
|
||||
#[cfg(not(test))]
|
||||
@@ -30,6 +32,7 @@ pub(super) fn parse_remote_opt(s: &str) -> Result<FileTransferParams, String> {
|
||||
|
||||
match protocol {
|
||||
FileTransferProtocol::AwsS3 => parse_s3_remote_opt(remote.as_str()),
|
||||
FileTransferProtocol::GoogleCloudStorage => parse_gcs_remote_opt(remote.as_str()),
|
||||
FileTransferProtocol::Kube => parse_kube_remote_opt(remote.as_str()),
|
||||
#[cfg(smb)]
|
||||
FileTransferProtocol::Smb => parse_smb_remote_opts(remote.as_str()),
|
||||
@@ -122,6 +125,20 @@ fn parse_s3_remote_opt(s: &str) -> Result<FileTransferParams, String> {
|
||||
.remote_path(remote_path))
|
||||
}
|
||||
|
||||
fn parse_gcs_remote_opt(s: &str) -> Result<FileTransferParams, String> {
|
||||
let groups = REMOTE_GCS_OPT_REGEX
|
||||
.captures(s)
|
||||
.ok_or_else(|| String::from("Bad Google Cloud Storage syntax!"))?;
|
||||
let bucket = required_capture(&groups, 1, "bucket")?;
|
||||
let remote_path = groups.get(2).map(|group| PathBuf::from(group.as_str()));
|
||||
|
||||
Ok(FileTransferParams::new(
|
||||
FileTransferProtocol::GoogleCloudStorage,
|
||||
ProtocolParams::GoogleCloudStorage(GoogleCloudStorageParams::new(bucket)),
|
||||
)
|
||||
.remote_path(remote_path))
|
||||
}
|
||||
|
||||
fn parse_kube_remote_opt(s: &str) -> Result<FileTransferParams, String> {
|
||||
let groups = REMOTE_KUBE_OPT_REGEX
|
||||
.captures(s)
|
||||
|
||||
Reference in New Issue
Block a user