From c8f56874d0fb4c53b41a4304520846a5791544a4 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 16 Nov 2024 16:09:07 +0100 Subject: [PATCH] feat: fix errors Signed-off-by: kjuulh --- crates/cuddle-ci/src/cuddle_please.rs | 4 +-- crates/cuddle-ci/src/drone_templater.rs | 4 +-- crates/cuddle-ci/src/rust_lib.rs | 2 +- crates/cuddle-ci/src/rust_service.rs | 25 +++++++------------ .../cuddle-ci/src/rust_service/dagger_bin.rs | 8 +++--- .../cuddle-ci/src/rust_service/ssh_agent.rs | 10 +++----- crates/dagger-cuddle-please/src/lib.rs | 12 +++------ crates/dagger-rust/src/build.rs | 2 -- crates/dagger-rust/src/htmx.rs | 2 -- crates/dagger-rust/src/leptos.rs | 2 -- 10 files changed, 25 insertions(+), 46 deletions(-) diff --git a/crates/cuddle-ci/src/cuddle_please.rs b/crates/cuddle-ci/src/cuddle_please.rs index 441b4e9..8d44639 100644 --- a/crates/cuddle-ci/src/cuddle_please.rs +++ b/crates/cuddle-ci/src/cuddle_please.rs @@ -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 } } } diff --git a/crates/cuddle-ci/src/drone_templater.rs b/crates/cuddle-ci/src/drone_templater.rs index 361b7af..7838713 100644 --- a/crates/cuddle-ci/src/drone_templater.rs +++ b/crates/cuddle-ci/src/drone_templater.rs @@ -18,7 +18,7 @@ pub struct DroneTemplater { impl DroneTemplater { pub fn new(client: dagger_sdk::Query, template: impl Into) -> 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( diff --git a/crates/cuddle-ci/src/rust_lib.rs b/crates/cuddle-ci/src/rust_lib.rs index aee6b92..a8eb0f4 100644 --- a/crates/cuddle-ci/src/rust_lib.rs +++ b/crates/cuddle-ci/src/rust_lib.rs @@ -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, diff --git a/crates/cuddle-ci/src/rust_service.rs b/crates/cuddle-ci/src/rust_service.rs index 760c459..44e7a6c 100644 --- a/crates/cuddle-ci/src/rust_service.rs +++ b/crates/cuddle-ci/src/rust_service.rs @@ -43,7 +43,7 @@ pub struct RustService { impl From 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 { - 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 { - 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"))] diff --git a/crates/cuddle-ci/src/rust_service/dagger_bin.rs b/crates/cuddle-ci/src/rust_service/dagger_bin.rs index cd7444a..69a287a 100644 --- a/crates/cuddle-ci/src/rust_service/dagger_bin.rs +++ b/crates/cuddle-ci/src/rust_service/dagger_bin.rs @@ -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"])) diff --git a/crates/cuddle-ci/src/rust_service/ssh_agent.rs b/crates/cuddle-ci/src/rust_service/ssh_agent.rs index 000e342..1d06c96 100644 --- a/crates/cuddle-ci/src/rust_service/ssh_agent.rs +++ b/crates/cuddle-ci/src/rust_service/ssh_agent.rs @@ -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) diff --git a/crates/dagger-cuddle-please/src/lib.rs b/crates/dagger-cuddle-please/src/lib.rs index 2680cad..20cdc75 100644 --- a/crates/dagger-cuddle-please/src/lib.rs +++ b/crates/dagger-cuddle-please/src/lib.rs @@ -194,10 +194,7 @@ impl DaggerCuddlePlease { }, ) .branch("main") - .tree_opts(dagger_sdk::GitRefTreeOpts { - ssh_auth_socket: Some(socket.id().await?), - ssh_known_hosts: None, - }) + .tree() } else { self.client .git_opts( @@ -288,17 +285,16 @@ impl DaggerCuddlePlease { .with_env_variable("SSH_AUTH_SOCK", "/tmp/ssh.sock") .with_new_file_opts( "/root/.ssh/config", - dagger_sdk::ContainerWithNewFileOpts { - contents: Some( - " + " Host * User git StrictHostKeyChecking no UserKnownHostsFile /dev/null ", - ), + dagger_sdk::ContainerWithNewFileOpts { owner: Some("root"), permissions: Some(700), + expand: None, }, ); diff --git a/crates/dagger-rust/src/build.rs b/crates/dagger-rust/src/build.rs index 13908a6..5eb4828 100644 --- a/crates/dagger-rust/src/build.rs +++ b/crates/dagger-rust/src/build.rs @@ -203,7 +203,6 @@ impl RustBuild { let base_debian = self .client .container_opts(dagger_sdk::QueryContainerOpts { - id: None, platform: Some(target.into_platform()), }) .from(image); @@ -234,7 +233,6 @@ impl RustBuild { let base_debian = self .client .container_opts(dagger_sdk::QueryContainerOpts { - id: None, platform: Some(target.into_platform()), }) .from(image); diff --git a/crates/dagger-rust/src/htmx.rs b/crates/dagger-rust/src/htmx.rs index d11af97..82c0725 100644 --- a/crates/dagger-rust/src/htmx.rs +++ b/crates/dagger-rust/src/htmx.rs @@ -200,7 +200,6 @@ impl HtmxBuild { let base_debian = self .client .container_opts(dagger_sdk::QueryContainerOpts { - id: None, platform: Some(target.into_platform()), }) .from(image); @@ -250,7 +249,6 @@ impl HtmxBuild { let base_debian = self .client .container_opts(dagger_sdk::QueryContainerOpts { - id: None, platform: Some(target.into_platform()), }) .from(image); diff --git a/crates/dagger-rust/src/leptos.rs b/crates/dagger-rust/src/leptos.rs index 4a25cda..dbfce6a 100644 --- a/crates/dagger-rust/src/leptos.rs +++ b/crates/dagger-rust/src/leptos.rs @@ -187,7 +187,6 @@ impl LeptosBuild { let base_debian = self .client .container_opts(dagger_sdk::QueryContainerOpts { - id: None, platform: Some(target.into_platform()), }) .from(image); @@ -237,7 +236,6 @@ impl LeptosBuild { let base_debian = self .client .container_opts(dagger_sdk::QueryContainerOpts { - id: None, platform: Some(target.into_platform()), }) .from(image);