Skip to main content

OciClient

Struct OciClient 

Source
pub struct OciClient(/* private fields */);
Expand description

An OCI client that wraps oci_client::Client.

Methods from Deref<Target = Client>§

Source

pub async fn store_auth_if_needed(&self, registry: &str, auth: &RegistryAuth)

Store the authentication information for this registry if it’s not already stored in the client.

Most of the time, you don’t need to call this method directly. It’s called by other methods (where you have to provide the authentication information as parameter).

But if you want to pull/push a blob without calling any of the other methods first, which would store the authentication information, you can call this method to store the authentication information manually.

Source

pub async fn list_tags( &self, image: &Reference, auth: &RegistryAuth, n: Option<usize>, last: Option<&str>, ) -> Result<TagResponse, OciDistributionError>

Fetches the available Tags for the given Reference

The client will check if it’s already been authenticated and if not will attempt to do.

Source

pub async fn pull( &self, image: &Reference, auth: &RegistryAuth, accepted_media_types: Vec<&str>, ) -> Result<ImageData, OciDistributionError>

Pull an image and return the bytes

The client will check if it’s already been authenticated and if not will attempt to do.

Source

pub async fn blob_exists( &self, image: &Reference, digest: &str, ) -> Result<bool, OciDistributionError>

Checks if a blob exists in the remote registry

Source

pub async fn push( &self, image_ref: &Reference, layers: &[ImageLayer], config: Config, auth: &RegistryAuth, manifest: Option<OciImageManifest>, ) -> Result<PushResponse, OciDistributionError>

Push an image and return the uploaded URL of the image

The client will check if it’s already been authenticated and if not will attempt to do.

If a manifest is not provided, the client will attempt to generate it from the provided image and config data.

Returns pullable URL for the image

Source

pub async fn push_blob( &self, image_ref: &Reference, data: impl Into<Bytes>, digest: &str, ) -> Result<String, OciDistributionError>

Pushes a blob to the registry

Source

pub async fn push_blob_stream<T>( &self, image: &Reference, blob_data_stream: T, blob_digest: &str, ) -> Result<String, OciDistributionError>

Pushes a blob to the registry as a series of chunks from an input stream

Returns the pullable location of the blob

Source

pub async fn auth( &self, image: &Reference, authentication: &RegistryAuth, operation: RegistryOperation, ) -> Result<Option<String>, OciDistributionError>

Perform an OAuth v2 auth request if necessary.

This performs authorization and then stores the token internally to be used on other requests.

Source

pub async fn fetch_manifest_digest( &self, image: &Reference, auth: &RegistryAuth, ) -> Result<String, OciDistributionError>

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.

Will first attempt to read the Docker-Content-Digest header using a HEAD request. If this header is not present, will make a second GET request and return the SHA256 of the response body.

Source

pub async fn pull_image_manifest( &self, image: &Reference, auth: &RegistryAuth, ) -> Result<(OciImageManifest, String), OciDistributionError>

Pull a manifest from the remote OCI Distribution service.

The client will check if it’s already been authenticated and if not will attempt to do.

A Tuple is returned containing the OciImageManifest and the manifest content digest hash.

If a multi-platform Image Index manifest is encountered, a platform-specific Image manifest will be selected using the client’s default platform resolution.

Source

pub async fn pull_manifest_raw( &self, image: &Reference, auth: &RegistryAuth, accepted_media_types: &[&str], ) -> Result<(Bytes, String), OciDistributionError>

Pull a manifest from the remote OCI Distribution service without parsing it.

The client will check if it’s already been authenticated and if not will attempt to do.

A Tuple is returned containing raw byte representation of the manifest and the manifest content digest.

Source

pub async fn pull_manifest( &self, image: &Reference, auth: &RegistryAuth, ) -> Result<(OciManifest, String), OciDistributionError>

Pull a manifest from the remote OCI Distribution service.

The client will check if it’s already been authenticated and if not will attempt to do.

A Tuple is returned containing the Manifest and the manifest content digest hash.

Source

pub async fn pull_manifest_and_config( &self, image: &Reference, auth: &RegistryAuth, ) -> Result<(OciImageManifest, String, String), OciDistributionError>

Pull a manifest and its config from the remote OCI Distribution service.

The client will check if it’s already been authenticated and if not will attempt to do.

A Tuple is returned containing the OciImageManifest, the manifest content digest hash and the contents of the manifests config layer as a String.

Source

pub async fn push_manifest_list( &self, reference: &Reference, auth: &RegistryAuth, manifest: OciImageIndex, ) -> Result<String, OciDistributionError>

Push a manifest list to an OCI registry.

This pushes a manifest list to an OCI registry.

Source

pub async fn pull_blob<T>( &self, image: &Reference, layer: impl AsLayerDescriptor, out: T, ) -> Result<(), OciDistributionError>
where T: AsyncWrite,

Pull a single layer from an OCI registry.

This pulls the layer for a particular image that is identified by the given layer descriptor. The layer descriptor can be anything that can be referenced as a layer descriptor. The image reference is used to find the repository and the registry, but it is not used to verify that the digest is a layer inside of the image. (The manifest is used for that.)

Source

pub async fn pull_blob_stream( &self, image: &Reference, layer: impl AsLayerDescriptor, ) -> Result<SizedStream, OciDistributionError>

Stream a single layer from an OCI registry.

This is a streaming version of Client::pull_blob. Returns SizedStream, which implements Stream or can be used directly to get the content length of the response

§Example
use std::future::Future;
use std::io::Error;

use futures_util::TryStreamExt;
use oci_client::{Client, Reference};
use oci_client::client::ClientConfig;
use oci_client::manifest::OciDescriptor;

async {
  let client = Client::new(Default::default());
  let imgRef: Reference = "busybox:latest".parse().unwrap();
  let desc = OciDescriptor { digest: "sha256:deadbeef".to_owned(), ..Default::default() };
  let mut stream = client.pull_blob_stream(&imgRef, &desc).await.unwrap();
  // Check the optional content length
  let content_length = stream.content_length.unwrap_or_default();
  // Use as a stream
  stream.try_next().await.unwrap().unwrap();
  // Use the underlying stream
  let mut stream = stream.stream;
};
Source

pub async fn pull_blob_stream_partial( &self, image: &Reference, layer: impl AsLayerDescriptor, offset: u64, length: Option<u64>, ) -> Result<BlobResponse, OciDistributionError>

Stream a single layer from an OCI registry starting with a byte offset. This can be used to continue downloading a layer after a network error. Please note that when doing a partial download (meaning it returns the BlobResponse::Partial variant), the layer digest is not verified as all the bytes are not available. The returned blob response will contain the header from the request digest, if it was set, that can be used (in addition to the digest from the layer) to verify the blob once all the bytes have been downloaded. Failure to do this means your content will not be verified.

Returns BlobResponse which indicates if the response was a full or partial response.

Source

pub async fn mount_blob( &self, image: &Reference, source: &Reference, digest: &str, ) -> Result<(), OciDistributionError>

Mounts a blob to the provided reference, from the given source

Source

pub async fn push_manifest( &self, image: &Reference, manifest: &OciManifest, ) -> Result<String, OciDistributionError>

Pushes the manifest for a specified image

Returns pullable manifest URL

Source

pub async fn push_manifest_raw( &self, image: &Reference, body: impl Into<Bytes>, content_type: HeaderValue, ) -> Result<String, OciDistributionError>

Pushes the manifest, provided as raw bytes, for a specified image

Returns pullable manifest url

Source

pub async fn pull_referrers( &self, image: &Reference, artifact_type: Option<&str>, ) -> Result<OciImageIndex, OciDistributionError>

Pulls the referrers for the given image filtering by the optionally provided artifact type.

Trait Implementations§

Source§

impl Clone for OciClient

Source§

fn clone(&self) -> OciClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for OciClient

Source§

fn default() -> OciClient

Returns the “default value” for a type. Read more
Source§

impl Deref for OciClient

Source§

type Target = Client

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetSetFdFlags for T

Source§

fn get_fd_flags(&self) -> Result<FdFlags, Error>
where T: AsFilelike,

Query the “status” flags for the self file descriptor.
Source§

fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>
where T: AsFilelike,

Create a new SetFdFlags value for use with set_fd_flags. Read more
Source§

fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>
where T: AsFilelike,

Set the “status” flags for the self file descriptor. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> QuoteExt for T
where T: ?Sized,

Source§

fn push_quoted<'q, Q, S>(&mut self, _q: Q, s: S)
where Q: QuoteInto<T>, S: Into<Quotable<'q>>,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more