thank you clippy now shut up

This commit is contained in:
Hamcha 2023-11-19 15:13:35 +01:00
parent 9777a7ec64
commit e085f734f8
4 changed files with 10 additions and 11 deletions

View File

@ -17,7 +17,7 @@ where
{
type Rejection = (StatusCode, &'static str);
async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection> {
if let Some(user_agent) = parts.headers.get(ACCEPT) {
Ok(ExtractAccept(user_agent.clone()))
} else {

View File

@ -27,7 +27,7 @@ impl From<ContainerInspectResponse> for ContainerInfo {
fn from(value: ContainerInspectResponse) -> Self {
ContainerInfo {
name: value.name.unwrap(),
state: value.state.map(|s| s.status).flatten().unwrap().to_string(),
state: value.state.and_then(|s| s.status).unwrap().to_string(),
image: value.image.unwrap(),
}
}

View File

@ -8,9 +8,9 @@ pub enum StackError {
NotFound,
}
impl Into<AppError> for StackError {
fn into(self) -> AppError {
match self {
impl From<StackError> for AppError {
fn from(value: StackError) -> Self {
match value {
StackError::NotFound => AppError::Client {
status: StatusCode::NOT_FOUND,
code: "stack-not-found",

View File

@ -2,12 +2,12 @@ use super::error::StackError;
use crate::http::error::Result;
use bollard::{container::ListContainersOptions, service::ContainerSummary, Docker};
use serde::Serialize;
use std::{collections::HashMap, path::PathBuf};
use std::{collections::HashMap, path::Path};
use tokio::fs::{read_dir, try_exists};
const COMPOSE_FILE: &str = "arion-compose.nix";
async fn is_stack(dir: &PathBuf) -> Result<bool> {
async fn is_stack(dir: &Path) -> Result<bool> {
Ok(try_exists(dir.join(COMPOSE_FILE)).await?)
}
@ -25,7 +25,7 @@ pub async fn get_containers(docker: &Docker, stack_name: &str) -> Result<Vec<Con
.await?)
}
pub async fn get_compose(base_dir: &PathBuf, stack_name: &str) -> Result<String> {
pub async fn get_compose(base_dir: &Path, stack_name: &str) -> Result<String> {
let dir = base_dir.join(stack_name);
if !is_stack(&dir).await? {
return Err(StackError::NotFound.into());
@ -41,7 +41,7 @@ pub struct StackInfo {
pub active: bool,
}
pub async fn list(base_dir: &PathBuf, docker: &Docker) -> Result<Vec<StackInfo>> {
pub async fn list(base_dir: &Path, docker: &Docker) -> Result<Vec<StackInfo>> {
let containers = docker
.list_containers(Some(ListContainersOptions {
all: false,
@ -65,8 +65,7 @@ pub async fn list(base_dir: &PathBuf, docker: &Docker) -> Result<Vec<StackInfo>>
let project = cont
.clone()
.labels
.map(|lab| lab.get("com.docker.compose.project").cloned())
.flatten()
.and_then(|lab| lab.get("com.docker.compose.project").cloned())
.unwrap_or_default();
name == project
});