feat: with ssh agent
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-12-30 21:55:29 +01:00
parent e67c4baa97
commit c759db28b0
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
2 changed files with 57 additions and 0 deletions

View File

@ -410,6 +410,7 @@ mod clap_sanity_test;
mod docker_cache; mod docker_cache;
mod mold; mod mold;
mod sqlx; mod sqlx;
mod ssh_agent;
pub mod extensions { pub mod extensions {
pub use super::apt::*; pub use super::apt::*;
@ -421,6 +422,7 @@ pub mod extensions {
pub use super::docker_cache::*; pub use super::docker_cache::*;
pub use super::mold::*; pub use super::mold::*;
pub use super::sqlx::*; pub use super::sqlx::*;
pub use super::ssh_agent::*;
} }
#[cfg(test)] #[cfg(test)]

View File

@ -0,0 +1,55 @@
use std::sync::Arc;
use async_trait::async_trait;
use dagger_sdk::{Container, Socket};
use crate::{dagger_middleware::DaggerMiddleware, leptos_service::LeptosService};
use super::RustService;
pub struct SshAgent {
socket: Socket,
}
impl SshAgent {
pub fn new(socket: Socket) -> Self {
Self { socket }
}
}
#[async_trait]
impl DaggerMiddleware for SshAgent {
async fn handle(&self, container: Container) -> eyre::Result<Container> {
let c = container.with_unix_socket("/tmp/ssh_socket", self.socket);
Ok(c)
}
}
pub trait SshAgentExt {
fn with_socket(&mut self, socket: dagger_sdk::Socket) -> &mut Self {
self
}
}
impl SshAgentExt for RustService {
fn with_socket(&mut self, socket: dagger_sdk::Socket) -> &mut Self {
self.with_stage(super::RustServiceStage::BeforeDeps(Arc::new(
SshAgent::new(socket.clone()).extend(deps),
)))
.with_stage(super::RustServiceStage::AfterBase(Arc::new(
SshAgent::new(socket.clone()).extend(deps),
)))
}
}
impl SshAgentExt for LeptosService {
fn with_socket(&mut self, socket: dagger_sdk::Socket) -> &mut Self {
self.with_stage(super::RustServiceStage::BeforeDeps(Arc::new(
SshAgent::new(socket.clone()).extend(deps),
)))
.with_stage(super::RustServiceStage::AfterBase(Arc::new(
SshAgent::new(socket.clone()).extend(deps),
)))
}
}