pub async fn pull_image(
        &mut self,
        image: &Reference,
        auth: &RegistryAuth,
    ) -> anyhow::Result<ImageData> {
        debug!("Pulling image: {:?}", image);

        if !self.tokens.contains_key(image.registry()) {
            self.auth(image, auth).await?;
        }

        let (manifest, digest) = self.pull_manifest(image).await?;

        let layers = manifest.layers.into_iter().map(|layer| {
            // This avoids moving `self` which is &mut Self
            // into the async block. We only want to capture
            // as &Self
            let this = &self;
            async move {
                let mut out: Vec<u8> = Vec::new();
                debug!("Pulling image layer");
                this.pull_layer(image, &layer.digest, &mut out).await?;
                Ok::<_, anyhow::Error>(out)
            }
        });

        let layers = future::try_join_all(layers).await?;
        let mut result = Vec::new();
        for layer in layers {
            // TODO: this simply overwrites previous layers with the latest one
            result = layer;
        }

        Ok(ImageData {
            content: result,
            digest: Some(digest),
        })
    }
/// Pull an image and return the bytes
///
/// The client will check if it's already been authenticated and if
/// not will attempt to do.
Pull an image and return the bytes
The client will check if it's already been authenticated and if
not will attempt to do.
Pull an image and return the bytes The client will check if it ' s already been authenticated and if not will attempt to do .
pub async fn pull_image(
        &mut self,
        image: &Reference,
        auth: &RegistryAuth,
    ) -> anyhow::Result<ImageData> {
        debug!("Pulling image: {:?}", image);
        if !self.tokens.contains_key(image.registry()) {
            self.auth(image, auth).await?;
        }
        let (manifest, digest) = self.pull_manifest(image).await?;
        let layers = manifest.layers.into_iter().map(|layer| {
            // This avoids moving `self` which is &mut Self
            // into the async block. We only want to capture
            // as &Self
            let this = &self;
            async move {
                let mut out: Vec<u8> = Vec::new();
                debug!("Pulling image layer");
                this.pull_layer(image, &layer.digest, &mut out).await?;
                Ok::<_, anyhow::Error>(out)
            }
        });
        let layers = future::try_join_all(layers).await?;
        let mut result = Vec::new();
        for layer in layers {
            // TODO: this simply overwrites previous layers with the latest one
            result = layer;
        }
        Ok(ImageData {
            content: result,
            digest: Some(digest),
        })
    }
pub async fn pull_image ( & mut self , image : & Reference , auth : & RegistryAuth , ) -> anyhow :: Result < ImageData > { debug ! ( " " image ) ; if ! self . tokens . contains_key ( image . registry ( ) ) { self . auth ( image , auth ) . await ? ; } let ( manifest , digest ) = self . pull_manifest ( image ) . await ? ; let layers = manifest . layers . into_iter ( ) . map ( | layer | { // This avoids moving `self` which is &mut Self // into the async block. We only want to capture // as &Self let this = & self ; async move { let mut out : Vec < u8 > = Vec :: new ( ) ; debug ! ( " " ) ; this . pull_layer ( image , & layer . digest , & mut out ) . await ? ; Ok :: < _ , anyhow :: Error > ( out ) } } ) ; let layers = future :: try_join_all ( layers ) . await ? ; let mut result = Vec :: new ( ) ; for layer in layers { // TODO: this simply overwrites previous layers with the latest one result = layer ; } Ok ( ImageData { content : result , digest : Some ( digest ) , } ) }
Pull an image and return the bytes
The client will check if it's already been authenticated and if
not will attempt to do.
Pull an image and return the bytes The client will check if it ' s already been authenticated and if not will attempt to do .
&mut self
image
&Reference
auth
&RegistryAuth
&mut self
image
&Reference
auth
&RegistryAuth