feat: with src
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-11-27 14:15:43 +01:00
parent a0acb54896
commit 85ad929d80
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -5,11 +5,24 @@ use crate::dagger_middleware::DaggerMiddleware;
use super::RustService;
pub struct Sqlx {}
pub struct Sqlx {
client: dagger_sdk::Query,
}
impl Sqlx {
pub fn new(client: dagger_sdk::Query) -> Self {
Self { client }
}
}
#[async_trait]
impl DaggerMiddleware for Sqlx {
async fn handle(&self, container: Container) -> eyre::Result<Container> {
Ok(container.with_env_variable("SQLX_OFFLINE", "true"))
let src = self.client.host().directory(".sqlx/");
Ok(container
.with_directory(".sqlx", src)
.with_env_variable("SQLX_OFFLINE", "true"))
}
}
@ -21,7 +34,9 @@ pub trait SqlxExt {
impl SqlxExt for RustService {
fn with_sqlx(&mut self) -> &mut Self {
self.with_stage(super::RustServiceStage::BeforeBuild(Box::new(Sqlx {})));
self.with_stage(super::RustServiceStage::BeforeBuild(Box::new(Sqlx::new(
self.client.clone(),
))));
self
}