pub async fn fetch_manifest_digest(
        &mut self,
        image: &Reference,
        auth: &RegistryAuth,
    ) -> anyhow::Result<String> {
        if !self.tokens.contains_key(image.registry()) {
            self.auth(image, auth).await?;
        }

        let url = self.to_v2_manifest_url(image);
        debug!("Pulling image manifest from {}", url);
        let request = self.client.get(&url);

        let res = request.headers(self.auth_headers(image)).send().await?;

        // The OCI spec technically does not allow any codes but 200, 500, 401, and 404.
        // Obviously, HTTP servers are going to send other codes. This tries to catch the
        // obvious ones (200, 4XX, 5XX). Anything else is just treated as an error.
        match res.status() {
            reqwest::StatusCode::OK => digest_header_value(&res),
            s if s.is_client_error() => {
                // According to the OCI spec, we should see an error in the message body.
                let err = res.json::<OciEnvelope>().await?;
                // FIXME: This should not have to wrap the error.
                Err(anyhow::anyhow!("{} on {}", err.errors[0], url))
            }
            s if s.is_server_error() => Err(anyhow::anyhow!("Server error at {}", url)),
            s => Err(anyhow::anyhow!(
                "An unexpected error occured: code={}, message='{}'",
                s,
                res.text().await?
            )),
        }
    }
/// Fetch a manifest's digest from the remote OCI Distribution service.
///
/// If the connection has already gone through authentication, this will
/// use the bearer token. Otherwise, this will attempt an anonymous pull.
Fetch a manifest's digest from the remote OCI Distribution service.
If the connection has already gone through authentication, this will
use the bearer token. Otherwise, this will attempt an anonymous pull.
Fetch a manifest ' s digest from the remote OCI Distribution service . If the connection has already gone through authentication this will use the bearer token . Otherwise this will attempt an anonymous pull .
pub async fn fetch_manifest_digest(
        &mut self,
        image: &Reference,
        auth: &RegistryAuth,
    ) -> anyhow::Result<String> {
        if !self.tokens.contains_key(image.registry()) {
            self.auth(image, auth).await?;
        }
        let url = self.to_v2_manifest_url(image);
        debug!("Pulling image manifest from {}", url);
        let request = self.client.get(&url);
        let res = request.headers(self.auth_headers(image)).send().await?;
        // The OCI spec technically does not allow any codes but 200, 500, 401, and 404.
        // Obviously, HTTP servers are going to send other codes. This tries to catch the
        // obvious ones (200, 4XX, 5XX). Anything else is just treated as an error.
        match res.status() {
            reqwest::StatusCode::OK => digest_header_value(&res),
            s if s.is_client_error() => {
                // According to the OCI spec, we should see an error in the message body.
                let err = res.json::<OciEnvelope>().await?;
                // FIXME: This should not have to wrap the error.
                Err(anyhow::anyhow!("{} on {}", err.errors[0], url))
            }
            s if s.is_server_error() => Err(anyhow::anyhow!("Server error at {}", url)),
            s => Err(anyhow::anyhow!(
                "An unexpected error occured: code={}, message='{}'",
                s,
                res.text().await?
            )),
        }
    }
pub async fn fetch_manifest_digest ( & mut self , image : & Reference , auth : & RegistryAuth , ) -> anyhow :: Result < String > { if ! self . tokens . contains_key ( image . registry ( ) ) { self . auth ( image , auth ) . await ? ; } let url = self . to_v2_manifest_url ( image ) ; debug ! ( " " url ) ; let request = self . client . get ( & url ) ; let res = request . headers ( self . auth_headers ( image ) ) . send ( ) . await ? ; // The OCI spec technically does not allow any codes but 200, 500, 401, and 404. // Obviously, HTTP servers are going to send other codes. This tries to catch the // obvious ones (200, 4XX, 5XX). Anything else is just treated as an error. match res . status ( ) { reqwest :: StatusCode :: OK => digest_header_value ( & res ) , s if s . is_client_error ( ) => { // According to the OCI spec, we should see an error in the message body. let err = res . json :: < OciEnvelope > ( ) . await ? ; // FIXME: This should not have to wrap the error. Err ( anyhow :: anyhow ! ( " " err errors [ 0 ] url ) ) } s if s . is_server_error ( ) => Err ( anyhow :: anyhow ! ( " " url ) ) , s => Err ( anyhow :: anyhow ! ( " " s res text ( ) await ) ) , } }
Fetch a manifest's digest from the remote OCI Distribution service.
Fetch a manifest ' s digest from the remote OCI Distribution service .
&mut self
image
&Reference
auth
&RegistryAuth
&mut self
image
&Reference
auth
&RegistryAuth