mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-07 08:27:12 +00:00
Simplify create_ssh_access return type and signature
Return just the SSH command string instead of the full SshAccessDto, and hardcode the 60-minute expiration internally. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e64f1e3c47
commit
b6bc58073b
3 changed files with 14 additions and 23 deletions
|
|
@ -488,10 +488,10 @@ pub async fn run_command(
|
|||
// Create SSH access if requested
|
||||
if args.ssh {
|
||||
if let Some(ref daytona) = daytona_sandbox_ref {
|
||||
match daytona.create_ssh_access(Some(60.0)).await {
|
||||
Ok(ssh_info) => {
|
||||
match daytona.create_ssh_access().await {
|
||||
Ok(ssh_command) => {
|
||||
emitter.emit(&crate::event::WorkflowRunEvent::SshAccessReady {
|
||||
ssh_command: ssh_info.ssh_command,
|
||||
ssh_command,
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
|
|||
|
|
@ -59,15 +59,14 @@ impl DaytonaSandbox {
|
|||
self.event_callback = Some(cb);
|
||||
}
|
||||
|
||||
pub async fn create_ssh_access(
|
||||
&self,
|
||||
expires_in_minutes: Option<f64>,
|
||||
) -> Result<daytona_sdk::api_types::SshAccessDto, String> {
|
||||
/// Create SSH access and return the connection command string.
|
||||
pub async fn create_ssh_access(&self) -> Result<String, String> {
|
||||
let sandbox = self.sandbox()?;
|
||||
sandbox
|
||||
.create_ssh_access(expires_in_minutes)
|
||||
let dto = sandbox
|
||||
.create_ssh_access(Some(60.0))
|
||||
.await
|
||||
.map_err(|e| format!("Failed to create SSH access: {e}"))
|
||||
.map_err(|e| format!("Failed to create SSH access: {e}"))?;
|
||||
Ok(dto.ssh_command)
|
||||
}
|
||||
|
||||
fn emit(&self, event: SandboxEvent) {
|
||||
|
|
|
|||
|
|
@ -1152,19 +1152,11 @@ async fn daytona_ssh_access() {
|
|||
let env = create_env().await;
|
||||
env.initialize().await.unwrap();
|
||||
|
||||
let ssh_info = env.create_ssh_access(Some(60.0)).await.unwrap();
|
||||
let ssh_command = env.create_ssh_access().await.unwrap();
|
||||
assert!(!ssh_command.is_empty(), "ssh_command should not be empty");
|
||||
assert!(
|
||||
!ssh_info.ssh_command.is_empty(),
|
||||
"ssh_command should not be empty"
|
||||
);
|
||||
assert!(
|
||||
ssh_info.ssh_command.contains("ssh"),
|
||||
"ssh_command should contain 'ssh': {}",
|
||||
ssh_info.ssh_command
|
||||
);
|
||||
assert!(
|
||||
!ssh_info.token.is_empty(),
|
||||
"token should not be empty"
|
||||
ssh_command.contains("ssh"),
|
||||
"ssh_command should contain 'ssh': {ssh_command}",
|
||||
);
|
||||
|
||||
env.cleanup().await.unwrap();
|
||||
|
|
@ -1175,7 +1167,7 @@ async fn daytona_ssh_access() {
|
|||
async fn daytona_ssh_access_before_init_fails() {
|
||||
let env = create_env().await;
|
||||
|
||||
let result = env.create_ssh_access(Some(60.0)).await;
|
||||
let result = env.create_ssh_access().await;
|
||||
assert!(result.is_err(), "should fail before initialize()");
|
||||
assert!(
|
||||
result.unwrap_err().contains("not initialized"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue