diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 74eba1a..0f8793e 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -50,4 +50,4 @@ pub enum Commands { /// Show version information Version, -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index d15be6a..cf6f2cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 { +fn get_project_name(project_path: &Path) -> Result { 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()) -} \ No newline at end of file +} diff --git a/src/registry/mod.rs b/src/registry/mod.rs index dbceb22..061c2b8 100644 --- a/src/registry/mod.rs +++ b/src/registry/mod.rs @@ -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) } }