This commit is contained in:
@@ -2,6 +2,56 @@
|
||||
|
||||
use std::fmt;
|
||||
|
||||
/// The transport Lumbridge uses to reach a user-owned remote machine.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum RemoteTransport {
|
||||
/// The system OpenSSH client, including the user's SSH config, `ProxyJump`,
|
||||
/// agent, and a Tailscale `MagicDNS` name or tailnet IP when supplied.
|
||||
OpenSsh,
|
||||
/// The Tailscale CLI's SSH proxy and host-key verification path.
|
||||
TailscaleSsh,
|
||||
}
|
||||
|
||||
impl RemoteTransport {
|
||||
#[must_use]
|
||||
pub const fn storage_name(self) -> &'static str {
|
||||
match self {
|
||||
Self::OpenSsh => "openssh",
|
||||
Self::TailscaleSsh => "tailscale-ssh",
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn from_storage_name(value: &str) -> Option<Self> {
|
||||
match value {
|
||||
"openssh" => Some(Self::OpenSsh),
|
||||
"tailscale-ssh" => Some(Self::TailscaleSsh),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A connection profile. It contains routing metadata, never credentials.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct RemoteHost {
|
||||
pub id: String,
|
||||
pub label: String,
|
||||
pub hostname: String,
|
||||
pub username: Option<String>,
|
||||
pub port: Option<u16>,
|
||||
pub transport: RemoteTransport,
|
||||
}
|
||||
|
||||
/// Where a workspace's processes and PTYs are owned.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum ExecutionTarget {
|
||||
Local,
|
||||
Remote {
|
||||
host_id: String,
|
||||
remote_path: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum Platform {
|
||||
MacOs,
|
||||
@@ -64,7 +114,7 @@ impl ProductStatus {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{Platform, ProductStatus, UsageProvenance};
|
||||
use super::{Platform, ProductStatus, RemoteTransport, UsageProvenance};
|
||||
|
||||
#[test]
|
||||
fn scaffold_status_is_explicit() {
|
||||
@@ -76,4 +126,14 @@ mod tests {
|
||||
fn usage_can_be_explicitly_unavailable() {
|
||||
assert_eq!(UsageProvenance::Unavailable, UsageProvenance::Unavailable);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remote_transport_storage_names_are_stable() {
|
||||
for transport in [RemoteTransport::OpenSsh, RemoteTransport::TailscaleSsh] {
|
||||
assert_eq!(
|
||||
RemoteTransport::from_storage_name(transport.storage_name()),
|
||||
Some(transport)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user