chore(rust): clippy fix

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-08-04 01:18:58 +02:00
parent d6e6dcb032
commit 78307ec8a3
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394
2 changed files with 40 additions and 40 deletions

View File

@ -2,19 +2,19 @@ use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use build::build_and_deploy;
use clap::Args; use clap::Args;
use clap::Parser; use clap::Parser;
use clap::Subcommand; use clap::Subcommand;
use clap::ValueEnum; use clap::ValueEnum;
use dagger_sdk::ContainerId;
use dagger_sdk::ContainerPublishOpts;
use dagger_sdk::Platform; use dagger_sdk::Platform;
use dagger_sdk::QueryContainerOpts; use dagger_sdk::QueryContainerOpts;
use futures::StreamExt; use futures::StreamExt;
use tokio::sync::Mutex;
use tokio::task::JoinHandle;
use crate::please_release::run_release_please; use crate::please_release::run_release_please;
@ -137,7 +137,7 @@ async fn main() -> eyre::Result<()> {
&cli.global, &cli.global,
&base_image, &base_image,
&prod_image, &prod_image,
&bin_name, bin_name,
&None, &None,
) )
.await?; .await?;
@ -158,11 +158,11 @@ async fn main() -> eyre::Result<()> {
image, image,
bin_name, bin_name,
} => { } => {
build::build_and_deploy(client, &cli.global, &bin_name, &image, &tag).await?; build::build_and_deploy(client, &cli.global, bin_name, image, tag).await?;
} }
LocalCommands::PleaseRelease => todo!(), LocalCommands::PleaseRelease => todo!(),
LocalCommands::BuildDocs {} => { LocalCommands::BuildDocs {} => {
let image = docs::execute( let _image = docs::execute(
client.clone(), client.clone(),
&cli.global, &cli.global,
&Some("linux/amd64".to_string()), &Some("linux/amd64".to_string()),
@ -179,10 +179,10 @@ async fn main() -> eyre::Result<()> {
let args = &cli.global; let args = &cli.global;
let base_image = let base_image =
base_rust_image(client.clone(), &args, &None, bin_name, &"debug".into()) base_rust_image(client.clone(), args, &None, bin_name, &"debug".into())
.await .await
.unwrap(); .unwrap();
test::execute(client.clone(), &args, base_image) test::execute(client.clone(), args, base_image)
.await .await
.unwrap(); .unwrap();
} }
@ -195,14 +195,14 @@ async fn main() -> eyre::Result<()> {
) { ) {
let args = &cli.global; let args = &cli.global;
build::build(client.clone(), &args, bin_name, image, tag) build::build(client.clone(), args, bin_name, image, tag)
.await .await
.unwrap(); .unwrap();
} }
tokio::join!( tokio::join!(
test(client.clone(), &cli, &bin_name), test(client.clone(), &cli, bin_name),
build(client.clone(), &cli, &bin_name, &image, &tag), build(client.clone(), &cli, bin_name, image, tag),
); );
} }
Commands::Main { Commands::Main {
@ -214,10 +214,10 @@ async fn main() -> eyre::Result<()> {
let args = &cli.global; let args = &cli.global;
let base_image = let base_image =
base_rust_image(client.clone(), &args, &None, bin_name, &"debug".into()) base_rust_image(client.clone(), args, &None, bin_name, &"debug".into())
.await .await
.unwrap(); .unwrap();
test::execute(client.clone(), &args, base_image) test::execute(client.clone(), args, base_image)
.await .await
.unwrap(); .unwrap();
} }
@ -230,7 +230,7 @@ async fn main() -> eyre::Result<()> {
) { ) {
let args = &cli.global; let args = &cli.global;
build::build_and_deploy(client.clone(), &args, bin_name, image, tag) build::build_and_deploy(client.clone(), args, bin_name, image, tag)
.await .await
.unwrap(); .unwrap();
} }
@ -242,8 +242,8 @@ async fn main() -> eyre::Result<()> {
} }
tokio::join!( tokio::join!(
test(client.clone(), &cli, &bin_name), test(client.clone(), &cli, bin_name),
build(client.clone(), &cli, &bin_name, &image, &tag), build(client.clone(), &cli, bin_name, image, tag),
cuddle_please(client.clone(), &cli) cuddle_please(client.clone(), &cli)
); );
} }
@ -257,9 +257,9 @@ mod please_release {
use std::sync::Arc; use std::sync::Arc;
use dagger_sdk::Container;
use crate::{base_rust_image, build, get_base_debian_image, get_rust_dep_src, GlobalArgs};
use crate::{base_rust_image, GlobalArgs};
pub async fn run_release_please( pub async fn run_release_please(
client: Arc<dagger_sdk::Query>, client: Arc<dagger_sdk::Query>,
@ -366,7 +366,7 @@ mod docs {
pub async fn execute( pub async fn execute(
client: Arc<dagger_sdk::Query>, client: Arc<dagger_sdk::Query>,
args: &GlobalArgs, args: &GlobalArgs,
platform: &Option<String>, _platform: &Option<String>,
) -> eyre::Result<Container> { ) -> eyre::Result<Container> {
let mkdocs_container = client.container().from( let mkdocs_container = client.container().from(
args.mkdocs_image args.mkdocs_image
@ -429,9 +429,9 @@ mod build {
use dagger_sdk::Container; use dagger_sdk::Container;
use futures::StreamExt;
use tokio::sync::Mutex;
use tokio::task::JoinHandle;
use crate::{base_rust_image, get_base_debian_image, GlobalArgs}; use crate::{base_rust_image, get_base_debian_image, GlobalArgs};
@ -453,7 +453,7 @@ mod build {
let container = base_rust_image( let container = base_rust_image(
client.clone(), client.clone(),
&args, args,
&Some("linux/amd64".to_string()), &Some("linux/amd64".to_string()),
&bin_name.clone(), &bin_name.clone(),
&"release".into(), &"release".into(),
@ -461,10 +461,10 @@ mod build {
.await?; .await?;
let build_image = execute( let build_image = execute(
client.clone(), client.clone(),
&args, args,
&container, &container,
&base_image, &base_image,
&bin_name, bin_name,
&Some("linux/amd64".to_string()), &Some("linux/amd64".to_string()),
) )
.await?; .await?;
@ -487,8 +487,8 @@ mod build {
client: Arc<dagger_sdk::Query>, client: Arc<dagger_sdk::Query>,
args: &GlobalArgs, args: &GlobalArgs,
bin_name: &String, bin_name: &String,
image: &String, _image: &String,
tag: &String, _tag: &String,
) -> eyre::Result<()> { ) -> eyre::Result<()> {
// let containers = vec!["linux/amd64", "linux/arm64"]; // let containers = vec!["linux/amd64", "linux/arm64"];
@ -501,7 +501,7 @@ mod build {
let container = base_rust_image( let container = base_rust_image(
client.clone(), client.clone(),
&args, args,
&Some("linux/amd64".to_string()), &Some("linux/amd64".to_string()),
&bin_name.clone(), &bin_name.clone(),
&"release".into(), &"release".into(),
@ -509,10 +509,10 @@ mod build {
.await?; .await?;
let build_image = execute( let build_image = execute(
client.clone(), client.clone(),
&args, args,
&container, &container,
&base_image, &base_image,
&bin_name, bin_name,
&Some("linux/amd64".to_string()), &Some("linux/amd64".to_string()),
) )
.await?; .await?;
@ -545,7 +545,7 @@ mod build {
rust_target, rust_target,
"--release", "--release",
"-p", "-p",
&bin_name, bin_name,
]); ]);
let final_image = base_image let final_image = base_image
@ -556,7 +556,7 @@ mod build {
.id() .id()
.await?, .await?,
) )
.with_exec(vec![&bin_name, "--help"]); .with_exec(vec![bin_name, "--help"]);
let output = final_image.stdout().await?; let output = final_image.stdout().await?;
println!("{output}"); println!("{output}");
@ -654,12 +654,12 @@ pub async fn get_rust_dep_src(
.build()?, .build()?,
); );
return Ok(directory); Ok(directory)
} }
pub async fn get_rust_skeleton_files( pub async fn get_rust_skeleton_files(
client: Arc<dagger_sdk::Query>, client: Arc<dagger_sdk::Query>,
args: &GlobalArgs, _args: &GlobalArgs,
) -> eyre::Result<(dagger_sdk::Directory, Vec<String>)> { ) -> eyre::Result<(dagger_sdk::Directory, Vec<String>)> {
let mut rust_crates = vec![PathBuf::from("ci")]; let mut rust_crates = vec![PathBuf::from("ci")];
let mut dirs = tokio::fs::read_dir("crates").await?; let mut dirs = tokio::fs::read_dir("crates").await?;
@ -701,7 +701,7 @@ pub async fn get_rust_skeleton_files(
if let Some(file_name) = rust_crate.file_name() { if let Some(file_name) = rust_crate.file_name() {
crate_names.push(file_name.to_str().unwrap().to_string()); crate_names.push(file_name.to_str().unwrap().to_string());
} }
directory = create_skeleton_files(directory, &rust_crate)?; directory = create_skeleton_files(directory, rust_crate)?;
} }
Ok((directory, crate_names)) Ok((directory, crate_names))
@ -739,7 +739,7 @@ pub async fn base_rust_image(
.with_exec(vec!["rustup", "target", "add", rust_target]); .with_exec(vec!["rustup", "target", "add", rust_target]);
let target_cache = client.cache_volume(format!("rust_target_{}", profile)); let target_cache = client.cache_volume(format!("rust_target_{}", profile));
let mut build_options = vec!["cargo", "build", "--target", rust_target, "-p", &bin_name]; let mut build_options = vec!["cargo", "build", "--target", rust_target, "-p", bin_name];
if profile == "release" { if profile == "release" {
build_options.push("--release"); build_options.push("--release");
@ -754,7 +754,7 @@ pub async fn base_rust_image(
let exclude = crates let exclude = crates
.iter() .iter()
.filter(|c| **c != "ci") .filter(|c| **c != "ci")
.map(|c| format!("**/*{}*", c.replace("-", "_"))) .map(|c| format!("**/*{}*", c.replace('-', "_")))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let exclude = exclude.iter().map(|c| c.as_str()).collect(); let exclude = exclude.iter().map(|c| c.as_str()).collect();

View File

@ -67,7 +67,7 @@ impl VcsClient {
"-c", "-c",
&format!("http.extraHeader='Authorization: token {}'", token), &format!("http.extraHeader='Authorization: token {}'", token),
"-c", "-c",
&format!("http.extraHeader='Sudo: kjuulh'"), "http.extraHeader='Sudo: kjuulh'",
"-c", "-c",
&format!("user.name={}", username), &format!("user.name={}", username),
"-c", "-c",