pub struct ImageImporter {
repo: Repo,
pub(crate) proxy: ImageProxy,
imgref: OstreeImageReference,
target_imgref: Option<OstreeImageReference>,
no_imgref: bool,
disable_gc: bool,
require_bootable: bool,
offline: bool,
ostree_v2024_3: bool,
layer_progress: Option<Sender<ImportProgress>>,
layer_byte_progress: Option<Sender<Option<LayerProgress>>>,
}Expand description
Context for importing a container image.
Fields§
§repo: Repo§proxy: ImageProxy§imgref: OstreeImageReference§target_imgref: Option<OstreeImageReference>§no_imgref: bool§disable_gc: bool§require_bootable: boolIf true, require the image has the bootable flag
offline: boolDo not attempt to contact the network
ostree_v2024_3: boolIf true, we have ostree v2024.3 or newer.
layer_progress: Option<Sender<ImportProgress>>§layer_byte_progress: Option<Sender<Option<LayerProgress>>>Implementations§
Source§impl ImageImporter
impl ImageImporter
Sourceconst CACHED_KEY_MANIFEST_DIGEST: &'static str = "ostree-ext.cached.manifest-digest"
const CACHED_KEY_MANIFEST_DIGEST: &'static str = "ostree-ext.cached.manifest-digest"
The metadata key used in ostree commit metadata to serialize
const CACHED_KEY_MANIFEST: &'static str = "ostree-ext.cached.manifest"
const CACHED_KEY_CONFIG: &'static str = "ostree-ext.cached.config"
Sourcepub async fn new(
repo: &Repo,
imgref: &OstreeImageReference,
config: ImageProxyConfig,
) -> Result<Self>
pub async fn new( repo: &Repo, imgref: &OstreeImageReference, config: ImageProxyConfig, ) -> Result<Self>
Create a new importer.
Sourcepub fn set_target(&mut self, target: &OstreeImageReference)
pub fn set_target(&mut self, target: &OstreeImageReference)
Write cached data as if the image came from this source.
Sourcepub fn set_no_imgref(&mut self)
pub fn set_no_imgref(&mut self)
Do not write the final image ref, but do write refs for shared layers. This is useful in scenarios where you want to “pre-pull” an image, but in such a way that it does not need to be manually removed later.
Sourcepub fn set_offline(&mut self)
pub fn set_offline(&mut self)
Do not attempt to contact the network
Sourcepub fn require_bootable(&mut self)
pub fn require_bootable(&mut self)
Require that the image has the bootable metadata field
Sourcepub fn set_ostree_version(&mut self, year: u32, v: u32)
pub fn set_ostree_version(&mut self, year: u32, v: u32)
Override the ostree version being targeted
Sourcepub fn disable_gc(&mut self)
pub fn disable_gc(&mut self)
Do not prune image layers.
Sourcepub async fn prepare(&mut self) -> Result<PrepareResult>
pub async fn prepare(&mut self) -> Result<PrepareResult>
Determine if there is a new manifest, and if so return its digest.
This will also serialize the new manifest and configuration into
metadata associated with the image, so that invocations of [query_cached]
can re-fetch it without accessing the network.
Sourcepub fn request_progress(&mut self) -> Receiver<ImportProgress>
pub fn request_progress(&mut self) -> Receiver<ImportProgress>
Create a channel receiver that will get notifications for layer fetches.
Sourcepub fn request_layer_progress(&mut self) -> Receiver<Option<LayerProgress>>
pub fn request_layer_progress(&mut self) -> Receiver<Option<LayerProgress>>
Create a channel receiver that will get notifications for byte-level progress of layer fetches.
Sourcepub(crate) async fn cache_pending(
&self,
commit: &str,
manifest_digest: &Digest,
manifest: &ImageManifest,
config: &ImageConfiguration,
) -> Result<()>
pub(crate) async fn cache_pending( &self, commit: &str, manifest_digest: &Digest, manifest: &ImageManifest, config: &ImageConfiguration, ) -> Result<()>
Serialize the metadata about a pending fetch as detached metadata on the commit object, so it can be retrieved later offline
Sourcefn create_prepared_import(
&mut self,
manifest_digest: Digest,
manifest: ImageManifest,
config: ImageConfiguration,
previous_state: Option<Box<LayeredImageState>>,
previous_imageid: Option<String>,
proxy_img: OpenedImage,
) -> Result<Box<PreparedImport>>
fn create_prepared_import( &mut self, manifest_digest: Digest, manifest: ImageManifest, config: ImageConfiguration, previous_state: Option<Box<LayeredImageState>>, previous_imageid: Option<String>, proxy_img: OpenedImage, ) -> Result<Box<PreparedImport>>
Given existing metadata (manifest, config, previous image statE) generate a PreparedImport structure which e.g. includes a diff of the layers.
Sourcepub(crate) async fn prepare_internal(
&mut self,
verify_layers: bool,
) -> Result<PrepareResult>
pub(crate) async fn prepare_internal( &mut self, verify_layers: bool, ) -> Result<PrepareResult>
Determine if there is a new manifest, and if so return its digest.
Sourcepub(crate) async fn unencapsulate_base(
&self,
import: &mut PreparedImport,
require_ostree: bool,
write_refs: bool,
) -> Result<()>
pub(crate) async fn unencapsulate_base( &self, import: &mut PreparedImport, require_ostree: bool, write_refs: bool, ) -> Result<()>
Extract the base ostree commit.
Sourcepub async fn unencapsulate(self) -> Result<Import>
pub async fn unencapsulate(self) -> Result<Import>
Retrieve an inner ostree commit.
This does not write cached references for each blob, and errors out if the image has any non-ostree layers.
Sourcefn write_merge_commit_impl(
repo: &Repo,
base_commit: Option<&str>,
layer_commits: &[String],
have_derived_layers: bool,
metadata: Variant,
timestamp: u64,
ostree_ref: &str,
no_imgref: bool,
disable_gc: bool,
cancellable: Option<&Cancellable>,
) -> Result<Box<LayeredImageState>>
fn write_merge_commit_impl( repo: &Repo, base_commit: Option<&str>, layer_commits: &[String], have_derived_layers: bool, metadata: Variant, timestamp: u64, ostree_ref: &str, no_imgref: bool, disable_gc: bool, cancellable: Option<&Cancellable>, ) -> Result<Box<LayeredImageState>>
Generate a single ostree commit that combines all layers, and also includes container image metadata such as the manifest and config.
Sourcepub async fn import(
self,
import: Box<PreparedImport>,
) -> Result<Box<LayeredImageState>>
pub async fn import( self, import: Box<PreparedImport>, ) -> Result<Box<LayeredImageState>>
Import a layered container image.
If enabled, this will also prune unused container image layers.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ImageImporter
impl !RefUnwindSafe for ImageImporter
impl Send for ImageImporter
impl !Sync for ImageImporter
impl Unpin for ImageImporter
impl !UnwindSafe for ImageImporter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more