use crate::error::Result;
use reqwest::Client;
pub struct OciClient {
client: Client,
registry_url: String,
}
impl OciClient {
pub fn new(registry_url: &str) -> Result<Self> {
Ok(Self {
client: Client::new(),
registry_url: registry_url.to_string(),
})
}
pub async fn pull_manifest(&self, reference: &str) -> Result<String> {
let (repo, tag) = self.parse_reference(reference)?;
let manifest_url = format!("{}/v2/{}/manifests/{}", self.registry_url, repo, tag);
println!("Would fetch manifest from: {}", manifest_url);
Ok("manifest".to_string())
}
pub async fn pull_blob(&self, digest: &str) -> Result<Vec<u8>> {
todo!("Implement OCI blob downloading")
}
fn parse_reference(&self, reference: &str) -> Result<(String, String)> {
let parts: Vec<&str> = reference.split(':').collect();
if parts.len() != 2 {
return Err(crate::error::SkillsetError::Oci(format!(
"Invalid reference format: {}",
reference
)));
}
Ok((parts[0].to_string(), parts[1].to_string()))
}
}