1
0
Fork 0
mirror of https://github.com/imjasonh/krust synced 2026-07-08 14:55:35 +00:00

Fix rustfmt and clippy issues

- Add missing newlines at end of files
- Remove trailing whitespace
- Use next_back() instead of last() for DoubleEndedIterator
- Use &Path instead of &PathBuf for function parameter

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jason Hall 2025-06-07 20:51:47 -04:00
parent 5e89023925
commit 2cf7ab1c17
Failed to extract signature
3 changed files with 15 additions and 17 deletions

View file

@ -50,4 +50,4 @@ pub enum Commands {
/// Show version information
Version,
}
}

View file

@ -7,7 +7,7 @@ use krust::{
image::ImageBuilder,
registry::RegistryClient,
};
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use tracing::{error, info};
use tracing_subscriber::EnvFilter;
@ -37,7 +37,7 @@ async fn main() -> Result<()> {
} => {
let config = Config::load()?;
let project_path = path.unwrap_or_else(|| PathBuf::from("."));
// Determine the image name
let image_ref = if let Some(image) = image {
// Use explicit image if provided
@ -72,7 +72,7 @@ async fn main() -> Result<()> {
let digest_ref = registry_client
.push_image(&image_ref, config_data, layers)
.await?;
// Print only the digest reference to stdout
println!("{}", digest_ref);
} else {
@ -93,19 +93,17 @@ async fn main() -> Result<()> {
Ok(())
}
fn get_project_name(project_path: &PathBuf) -> Result<String> {
fn get_project_name(project_path: &Path) -> Result<String> {
let cargo_toml_path = project_path.join("Cargo.toml");
let content = std::fs::read_to_string(&cargo_toml_path)
.context("Failed to read Cargo.toml")?;
let manifest: toml::Value = toml::from_str(&content)
.context("Failed to parse Cargo.toml")?;
let content = std::fs::read_to_string(&cargo_toml_path).context("Failed to read Cargo.toml")?;
let manifest: toml::Value = toml::from_str(&content).context("Failed to parse Cargo.toml")?;
let name = manifest
.get("package")
.and_then(|p| p.get("name"))
.and_then(|n| n.as_str())
.context("Failed to get package name from Cargo.toml")?;
Ok(name.to_string())
}
}

View file

@ -87,19 +87,19 @@ impl RegistryClient {
.context("Failed to push manifest")?;
info!("Successfully pushed image to {}", manifest_url);
// Extract digest from the manifest URL
// URL format: https://registry/v2/repo/manifests/sha256:digest
let digest = manifest_url
.split('/')
.last()
.next_back()
.context("Failed to extract digest from manifest URL")?;
// Build the full image reference with digest
let registry = reference.registry();
let repository = reference.repository();
let digest_ref = format!("{}/{}@{}", registry, repository, digest);
Ok(digest_ref)
}
}