Giter Club home page Giter Club logo

oci-registry-client's Introduction

OCI Registry Client

crates.io Documentation MIT

A async client for OCI compliant image registries and Docker Registry HTTP V2 protocol.

Usage

The [DockerRegistryClientV2] provides functions to query Registry API and download blobs.

use std::{path::Path, fs::File, io::Write};
use oci_registry_client::DockerRegistryClientV2;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = DockerRegistryClientV2::new(
        "registry.docker.io",
        "https://registry-1.docker.io",
        "https://auth.docker.io/token"
    );
    let token = client.auth("repository", "library/ubuntu", "latest").await?;
    client.set_auth_token(Some(token));

    let manifest = client.manifest("library/ubuntu", "latest").await?;
    println!("{:?}", manifest);

    for layer in &manifest.layers {
       let mut out_file = File::create(Path::new("/tmp/").join(&layer.digest))?;
       let mut blob = client.blob("library/ubuntu", &layer.digest).await?;

       while let Some(chunk) = blob.chunk().await? {
           out_file.write_all(&chunk)?;
       }
    }

    Ok(())
}

License

This project is licensed under the MIT License.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in oci-registry-client by you, shall be licensed as MIT, without any additional terms or conditions.

oci-registry-client's People

Contributors

ecarrara avatar nisimond avatar no9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.