pub struct ImageImporter {Show 13 fields
repo: Repo,
pub(crate) proxy: ImageProxy,
imgref: OstreeImageReference,
target_imgref: Option<OstreeImageReference>,
no_imgref: bool,
disable_gc: bool,
sepolicy_commit: Option<String>,
require_bootable: bool,
offline: bool,
ostree_v2024_3: bool,
diffid_to_digest: HashMap<String, String>,
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§sepolicy_commit: Option<String>Optional commit to use as SELinux policy source for non-ostree container layers.
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.
diffid_to_digest: HashMap<String, String>Mapping from diff_id to blob digest for layer deduplication
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 fn set_sepolicy_commit(&mut self, commit: String)
pub fn set_sepolicy_commit(&mut self, commit: String)
Set the commit to use as SELinux policy source when importing non-ostree container layers. Has no effect on ostree-native containers (which have their own base commit).
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 build_diffid_to_digest_map(repo: &Repo) -> Result<HashMap<String, String>>
fn build_diffid_to_digest_map(repo: &Repo) -> Result<HashMap<String, String>>
Build a mapping from diff_id to blob_digest by enumerating all stored images. This allows us to reuse layers with the same content even if they have different blob digests.
fn find_digest_by_diffid( &self, manifest: &ImageManifest, config: &ImageConfiguration, layer: &Descriptor, ) -> Option<&String>
Sourcefn resolve_commit_by_diffid(
&self,
manifest: &ImageManifest,
config: &ImageConfiguration,
layer: &Descriptor,
) -> Result<Option<String>>
fn resolve_commit_by_diffid( &self, manifest: &ImageManifest, config: &ImageConfiguration, layer: &Descriptor, ) -> Result<Option<String>>
Try to resolve a layer commit by looking up its diff_id in already-imported images.
Sourcefn query_layer(
&self,
manifest: &ImageManifest,
config: &ImageConfiguration,
layer: &Descriptor,
) -> Result<ManifestLayerState>
fn query_layer( &self, manifest: &ImageManifest, config: &ImageConfiguration, layer: &Descriptor, ) -> Result<ManifestLayerState>
Query a layer by digest, falling back to diff_id lookup if the direct ref is not found.
Sourcefn ensure_ref_for_layer(
repo: &Repo,
ostree_ref: &str,
commit: &str,
) -> Result<()>
fn ensure_ref_for_layer( repo: &Repo, ostree_ref: &str, commit: &str, ) -> Result<()>
Ensure a ref exists for a layer, creating it if needed.
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: &[LayerRef],
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: &[LayerRef], 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.
Sourcefn relabel_layers(
repo: &Repo,
layer_commits: &[LayerRef],
modifier: &RepoCommitModifier,
checkout_mode: RepoCheckoutMode,
cancellable: Option<&Cancellable>,
) -> Result<u32>
fn relabel_layers( repo: &Repo, layer_commits: &[LayerRef], modifier: &RepoCommitModifier, checkout_mode: RepoCheckoutMode, cancellable: Option<&Cancellable>, ) -> Result<u32>
Relabel layer commits with the given commit modifier (which carries an SELinux policy). Each layer is checked out, recommitted with the policy applied, and its ref is updated to point at the new commit. Returns the number of layers that were actually relabeled (i.e. whose commit changed).
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