GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - oras-project/rust-oci-client: A Rust crate to interact with OCI registries

BranchesTags
Open more actions menu

Latest commit

 

History

1,611 Commits
1,611 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
examples
examples
 
 
src
src
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
CODEOWNERS
CODEOWNERS
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
Cargo.toml
Cargo.toml
 
 
LICENSE
LICENSE
 
 
OWNERS.md
OWNERS.md
 
 
README.md
README.md
 
 
deny.toml
deny.toml
 
 
justfile
justfile
 
 
justfile-windows
justfile-windows
 
 

Repository files navigation

Rust OCI Client

Formerly known as oci-distribution

oci-client documentation

This Rust library implements the OCI Distribution specification, which is the protocol that Docker Hub and other container registries use.

TLS backends

This crate has three Cargo features for TLS. If you use the default HTTP transport, you must enable exactly one of them.

  • rustls-tls (default): Uses the rustls library with its built-in aws-lc-rs crypto provider.
  • rustls-tls-no-provider: Uses rustls, but leaves the crypto provider to you. Before you build a Client, install one, for example with rustls::crypto::ring::default_provider().install_default(). Choose this feature when your application already picks a crypto provider and you want to avoid aws-lc-rs.
  • native-tls: Uses the TLS library of your operating system instead of rustls.

You do not have to enable a TLS feature in two cases:

  • You give the client your own HTTP transport. The transport supplies TLS.
  • You build for wasm32-unknown-unknown. The browser supplies TLS. The features have no effect.

The next section explains how to use a custom transport.

Custom HTTP transport

By default, Client sends its requests with a reqwest client that it builds from ClientConfig. An application can have an HTTP stack of its own, for example for a TLS policy, observability or traffic shaping. Such an application can give its stack to Client::new_with_transport as a cloneable Tower service.

The client prepares each request fully: the URL, the method, the headers and the body. The headers include User-Agent and the registry credentials. Then the client gives the request to the transport. The transport controls all the network work: connections, TLS, proxies, timeouts and retries.

The transport must also follow redirects. A redirect is a response that tells the client to send the request to a different URL. Registries often redirect blob downloads to a CDN or to an object store. As a result, a transport that does not follow redirects cannot pull images.

A transport that follows a redirect can record the URL it ended on in a transport::EffectiveUrl extension of the response. The client reads this URL for its error messages. A transport built on tower_http::follow_redirect::FollowRedirectLayer must copy the final URL from that layer's own extension into an EffectiveUrl, as the custom-transport example shows.

On wasm32-unknown-unknown, the default transport uses the Fetch API of the browser. The browser controls TLS, proxies, timeouts and redirects, so the client ignores the related fields of ClientConfig.

The custom-transport example builds a transport from hyper, rustls and tower layers. Run it with this command:

cargo run --example custom-transport -- docker.io/library/hello-world:latest

To see a trace of each HTTP exchange, add --verbose. The trace also shows the blob download that the registry redirects.

Client::new_with_transport does not build a reqwest client or a TLS backend. Some fields of ClientConfig only configure the default transport: the TLS fields, the proxies and the timeouts. With a custom transport, the client ignores them. The client uses all the other fields, for example protocol and user_agent.

Code of Conduct

This project has adopted the CNCF Code of Conduct.

About

A Rust crate to interact with OCI registries

Topics

cncfcontainer-image-registrycontainerskubernetesocioci-artifactsoci-image

Resources

Readme
Apache-2.0 license

Contributing

Contributing
Activity
Custom properties

Stars

191 stars

Watchers

8 watching

Forks

93 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.