feat: fix errors
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-11-16 16:09:07 +01:00
parent 66efb97120
commit c8f56874d0
10 changed files with 25 additions and 46 deletions

View File

@@ -10,9 +10,7 @@ pub struct CuddlePlease {
impl CuddlePlease {
pub fn new(client: dagger_sdk::Query) -> Self {
Self {
client: client.pipeline("cuddle-please"),
}
Self { client }
}
}

View File

@@ -18,7 +18,7 @@ pub struct DroneTemplater {
impl DroneTemplater {
pub fn new(client: dagger_sdk::Query, template: impl Into<PathBuf>) -> Self {
Self {
client: client.pipeline("drone-templater"),
client,
template: template.into(),
variables: BTreeMap::default(),
}
@@ -56,7 +56,7 @@ impl MainAction for DroneTemplater {
let template_name = self.template.display().to_string();
let mut cmd = vec!["drone-templater", "upload", "--template", &template_name]
let cmd = vec!["drone-templater", "upload", "--template", &template_name]
.into_iter()
.map(|v| v.to_string())
.chain(

View File

@@ -23,7 +23,7 @@ pub struct RustLib {
impl RustLib {
pub fn new(value: dagger_sdk::Query) -> Self {
Self {
client: value.pipeline("rust-lib"),
client: value,
source: None,
crates: Vec::new(),
arch: None,

View File

@@ -43,7 +43,7 @@ pub struct RustService {
impl From<dagger_sdk::Query> for RustService {
fn from(value: dagger_sdk::Query) -> Self {
Self {
client: value.pipeline("rust-service"),
client: value,
base_image: None,
final_image: None,
stages: Vec::new(),
@@ -168,8 +168,8 @@ impl RustService {
}
pub async fn build_base(&self) -> eyre::Result<Container> {
let client = self.client.pipeline("build-base");
let rust_src = RustSource::new(client.pipeline("load-source"));
let client = self.client.clone();
let rust_src = RustSource::new(client.clone());
let (src, dep_src) = rust_src
.get_rust_src(Some(&self.get_src()), self.crates.clone())
@@ -245,8 +245,8 @@ impl RustService {
}
pub async fn build_release(&self) -> eyre::Result<Container> {
let base = self.build_base().await?.pipeline("build-release");
let client = self.client.pipeline("build-release");
let base = self.build_base().await?;
let client = self.client.clone();
let before_build = self
.stages
@@ -305,7 +305,7 @@ impl RustService {
}
pub async fn build_test(&self) -> eyre::Result<()> {
let base = self.build_base().await?.pipeline("build-test");
let base = self.build_base().await?;
let before_build = self
.stages
@@ -330,7 +330,7 @@ impl PullRequestAction for RustService {
async fn execute_pull_request(&self, ctx: &mut Context) -> eyre::Result<()> {
self.build_test().await?;
let container = self.build_release().await?.pipeline("pr");
let container = self.build_release().await?;
let timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
@@ -372,7 +372,7 @@ impl RustServiceContext for Context {
#[async_trait]
impl MainAction for RustService {
async fn execute_main(&self, ctx: &mut Context) -> eyre::Result<()> {
let container = self.build_release().await?.pipeline("main");
let container = self.build_release().await?;
let timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
@@ -488,14 +488,7 @@ pub mod extensions {
#[cfg(test)]
mod test {
use crate::rust_service::{
apt::AptExt,
architecture::{Architecture, Os},
cargo_binstall::CargoBInstallExt,
clap_sanity_test::ClapSanityTestExt,
mold::MoldActionExt,
RustService,
};
#[tokio::test]
#[cfg(any(feature = "dagger", feature = "integration"))]

View File

@@ -1,7 +1,7 @@
use std::sync::Arc;
use async_trait::async_trait;
use dagger_sdk::{Container, ImageMediaTypes};
use dagger_sdk::Container;
use crate::dagger_middleware::DaggerMiddleware;
@@ -35,7 +35,8 @@ impl DaggerMiddleware for DaggerBin {
install_script,
dagger_sdk::ContainerWithFileOpts {
owner: None,
permissions: Some(0755),
permissions: Some(0o755),
expand: None,
},
)
.with_env_variable("DAGGER_VERSION", &self.version)
@@ -48,7 +49,8 @@ impl DaggerMiddleware for DaggerBin {
dagger_bin,
dagger_sdk::ContainerWithFileOpts {
owner: None,
permissions: Some(0755),
permissions: Some(0o755),
expand: None,
},
)
.with_exec(vec!["/usr/local/bin/dagger", "version"]))

View File

@@ -26,21 +26,17 @@ impl DaggerMiddleware for SshAgent {
let socket = self.client.host().unix_socket(&sock_var);
let home = container.env_variable("HOME").await.unwrap_or("".into());
let c = container
.with_new_file_opts(
".ssh/config".to_string(),
ContainerWithNewFileOptsBuilder::default()
.contents(
r#"
r#"
Host *
UserKnownHostsFile=/dev/null
StrictHostKeyChecking no
"#,
)
.permissions(0700_isize)
ContainerWithNewFileOptsBuilder::default()
.permissions(0o700_isize)
.build()?,
)
.with_unix_socket(&sock_var, socket)