mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 21:21:32 +00:00
hypha: implement OCI image layer spec
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
use crate::error::{HyphaError, Result};
|
||||
use oci_spec::image::{Arch, Descriptor, ImageIndex, ImageManifest, MediaType, Os, ToDockerV2S2};
|
||||
use std::io::Read;
|
||||
use std::io::copy;
|
||||
use std::io::{Read, Write};
|
||||
use std::ops::DerefMut;
|
||||
use ureq::{Agent, Request, Response};
|
||||
use url::Url;
|
||||
|
||||
@ -31,6 +33,20 @@ impl RegistryClient {
|
||||
Ok(buffer)
|
||||
}
|
||||
|
||||
pub fn write_blob(
|
||||
&mut self,
|
||||
name: &str,
|
||||
descriptor: &Descriptor,
|
||||
dest: &mut dyn Write,
|
||||
) -> Result<u64> {
|
||||
let url = self
|
||||
.url
|
||||
.join(&format!("/v2/{}/blobs/{}", name, descriptor.digest()))?;
|
||||
let response = self.call(self.agent.get(url.as_str()))?;
|
||||
let mut reader = response.into_reader();
|
||||
Ok(copy(reader.deref_mut(), dest)?)
|
||||
}
|
||||
|
||||
pub fn get_manifest(&mut self, name: &str, reference: &str) -> Result<ImageManifest> {
|
||||
let url = self
|
||||
.url
|
||||
|
Reference in New Issue
Block a user