OCI version function was showing as dead code
@@ -17,8 +17,6 @@ use std::collections::HashMap;
use tokio::io::{AsyncWrite, AsyncWriteExt};
use www_authenticate::{Challenge, ChallengeFields, RawChallenge, WwwAuthenticate};
-const OCI_VERSION_KEY: &str = "Docker-Distribution-Api-Version";
-
/// The data for an image or module.
#[derive(Clone)]
pub struct ImageData {
@@ -98,23 +96,6 @@ impl Client {
})
}
- /// According to the v2 specification, 200 and 401 error codes MUST return the
- /// version. It appears that any other response code should be deemed non-v2.
- ///
- /// For this implementation, it will return v2 or an error result. If the error is a
- /// `reqwest` error, the request itself failed. All other error messages mean that
- /// v2 is not supported.
- async fn version(&self, host: &str) -> anyhow::Result<String> {
- let url = format!("{}://{}/v2/", self.config.protocol.as_str(), host);
- let res = self.client.get(&url).send().await?;
- let dist_hdr = res.headers().get(OCI_VERSION_KEY);
- let version = dist_hdr
- .ok_or_else(|| anyhow::anyhow!("no header v2 found"))?
- .to_str()?
- .to_owned();
- Ok(version)
- }
-
/// Perform an OAuth v2 auth request if necessary.
///
/// This performs authorization and then stores the token internally to be used
@@ -399,16 +380,6 @@ mod test {
const HELLO_IMAGE: &str = "webassembly.azurecr.io/hello-wasm:v1";
- #[tokio::test]
- async fn test_version() {
- let c = Client::default();
- let ver = c
- .version("webassembly.azurecr.io")
- .await
- .expect("result from version request");
- assert_eq!("registry/2.0".to_owned(), ver);
- }
-
#[tokio::test]
async fn test_auth() {
let image = Reference::try_from(HELLO_IMAGE).expect("failed to parse reference");
