mirror of
https://github.com/imjasonh/krust
synced 2026-07-20 13:20:11 +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:
parent
5e89023925
commit
2cf7ab1c17
3 changed files with 15 additions and 17 deletions
|
|
@ -50,4 +50,4 @@ pub enum Commands {
|
||||||
|
|
||||||
/// Show version information
|
/// Show version information
|
||||||
Version,
|
Version,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
src/main.rs
22
src/main.rs
|
|
@ -7,7 +7,7 @@ use krust::{
|
||||||
image::ImageBuilder,
|
image::ImageBuilder,
|
||||||
registry::RegistryClient,
|
registry::RegistryClient,
|
||||||
};
|
};
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ async fn main() -> Result<()> {
|
||||||
} => {
|
} => {
|
||||||
let config = Config::load()?;
|
let config = Config::load()?;
|
||||||
let project_path = path.unwrap_or_else(|| PathBuf::from("."));
|
let project_path = path.unwrap_or_else(|| PathBuf::from("."));
|
||||||
|
|
||||||
// Determine the image name
|
// Determine the image name
|
||||||
let image_ref = if let Some(image) = image {
|
let image_ref = if let Some(image) = image {
|
||||||
// Use explicit image if provided
|
// Use explicit image if provided
|
||||||
|
|
@ -72,7 +72,7 @@ async fn main() -> Result<()> {
|
||||||
let digest_ref = registry_client
|
let digest_ref = registry_client
|
||||||
.push_image(&image_ref, config_data, layers)
|
.push_image(&image_ref, config_data, layers)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Print only the digest reference to stdout
|
// Print only the digest reference to stdout
|
||||||
println!("{}", digest_ref);
|
println!("{}", digest_ref);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -93,19 +93,17 @@ async fn main() -> Result<()> {
|
||||||
Ok(())
|
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 cargo_toml_path = project_path.join("Cargo.toml");
|
||||||
let content = std::fs::read_to_string(&cargo_toml_path)
|
let content = std::fs::read_to_string(&cargo_toml_path).context("Failed to read Cargo.toml")?;
|
||||||
.context("Failed to read Cargo.toml")?;
|
|
||||||
|
let manifest: toml::Value = toml::from_str(&content).context("Failed to parse Cargo.toml")?;
|
||||||
let manifest: toml::Value = toml::from_str(&content)
|
|
||||||
.context("Failed to parse Cargo.toml")?;
|
|
||||||
|
|
||||||
let name = manifest
|
let name = manifest
|
||||||
.get("package")
|
.get("package")
|
||||||
.and_then(|p| p.get("name"))
|
.and_then(|p| p.get("name"))
|
||||||
.and_then(|n| n.as_str())
|
.and_then(|n| n.as_str())
|
||||||
.context("Failed to get package name from Cargo.toml")?;
|
.context("Failed to get package name from Cargo.toml")?;
|
||||||
|
|
||||||
Ok(name.to_string())
|
Ok(name.to_string())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,19 +87,19 @@ impl RegistryClient {
|
||||||
.context("Failed to push manifest")?;
|
.context("Failed to push manifest")?;
|
||||||
|
|
||||||
info!("Successfully pushed image to {}", manifest_url);
|
info!("Successfully pushed image to {}", manifest_url);
|
||||||
|
|
||||||
// Extract digest from the manifest URL
|
// Extract digest from the manifest URL
|
||||||
// URL format: https://registry/v2/repo/manifests/sha256:digest
|
// URL format: https://registry/v2/repo/manifests/sha256:digest
|
||||||
let digest = manifest_url
|
let digest = manifest_url
|
||||||
.split('/')
|
.split('/')
|
||||||
.last()
|
.next_back()
|
||||||
.context("Failed to extract digest from manifest URL")?;
|
.context("Failed to extract digest from manifest URL")?;
|
||||||
|
|
||||||
// Build the full image reference with digest
|
// Build the full image reference with digest
|
||||||
let registry = reference.registry();
|
let registry = reference.registry();
|
||||||
let repository = reference.repository();
|
let repository = reference.repository();
|
||||||
let digest_ref = format!("{}/{}@{}", registry, repository, digest);
|
let digest_ref = format!("{}/{}@{}", registry, repository, digest);
|
||||||
|
|
||||||
Ok(digest_ref)
|
Ok(digest_ref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue