project: Use ImageReference from containers_image_proxy#2204
Draft
Johan-Liebert1 wants to merge 1 commit into
Draft
project: Use ImageReference from containers_image_proxy#2204Johan-Liebert1 wants to merge 1 commit into
Johan-Liebert1 wants to merge 1 commit into
Conversation
Refactor `struct ImageReference` as an alias to `containers_image_proxy::ImageReference`, also refactor `enum Transport` as Transport from containers_image_proxy Rename `crate::lib::spec::ImageReference` to `ImageReferenceSig` to avoid confusion with ImageReference from containers_image_proxy Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Open
Contributor
There was a problem hiding this comment.
Code Review
This pull request renames the ImageReference struct to ImageReferenceSig across the library and replaces internal definitions of Transport and ImageReference in crates/ostree-ext with type aliases from containers_image_proxy. The review feedback identifies several opportunities to simplify the code by removing redundant Ok(...?) wrapping and explicit anyhow:: prefixes, as well as cleaning up a trailing doc comment in the container module.
| /// Parse a base [`ImageReference`] from a CLI argument. | ||
| pub fn parse_base_imgref(s: &str) -> Result<ImageReference> { | ||
| ImageReference::try_from(s) | ||
| Ok(ImageReference::try_from(s)?) |
Contributor
| let all_images = all_images | ||
| .into_iter() | ||
| .map(|img| crate::container::ImageReference::try_from(img.as_str())) | ||
| .map(|img| -> Result<_> { Ok(crate::container::ImageReference::try_from(img.as_str())?) }) |
Contributor
There was a problem hiding this comment.
The closure can be simplified by removing the redundant Ok(...?) wrapping and explicit return type annotation, as try_from already returns the expected Result type.
Suggested change
| .map(|img| -> Result<_> { Ok(crate::container::ImageReference::try_from(img.as_str())?) }) | |
| .map(|img| crate::container::ImageReference::try_from(img.as_str())) |
Comment on lines
192
to
194
| /// Combination of a remote image reference and transport. | ||
| /// | ||
| /// For example, |
Contributor
There was a problem hiding this comment.
| }) | ||
| .chain(deployment_commits.into_iter().map(Ok)) | ||
| .collect::<Result<Vec<_>>>()?; | ||
| .collect::<anyhow::Result<Vec<_>>>()?; |
Contributor
|
rerun |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor
struct ImageReferenceas an alias tocontainers_image_proxy::ImageReference, also refactorenum Transportas Transport from containers_image_proxyRename
crate::lib::spec::ImageReferencetoImageReferenceSigto avoid confusion with ImageReference from containers_image_proxyRequires: bootc-dev/containers-image-proxy-rs#138