Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch blob as stream #224

Merged
merged 6 commits into from
Jul 8, 2022
Merged

Fetch blob as stream #224

merged 6 commits into from
Jul 8, 2022

Conversation

anti-social
Copy link
Contributor

@anti-social anti-social commented Feb 7, 2022

Here we need this functionality: tailhook/vagga#572

Copy link
Contributor

@vrutkovs vrutkovs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR! Some notes below

pub fn try_verify(&self, input: &[u8]) -> std::result::Result<(), ContentDigestError> {
let hash = self.algorithm.hash(input);
let layer_digest = Self::try_new(hash)?;
pub fn hash(&mut self, input: &[u8]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this function does - if it just updates self.algorithm lets rename it to smth like detect_hash_type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename it to update - it is well known name when hashing data.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

/// ContentDigest stores a digest and its DigestAlgorithm
#[derive(Clone, Debug)]
pub struct ContentDigest {
expected_digest: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it needs to be renamed, its unclear what "expected" means here

Ok(())
}
}

impl std::fmt::Display for ContentDigest {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}:{}", self.algorithm, self.digest)
write!(f, "{}:{}", self.algorithm, "self.digest")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think quotes are necessary - typo?

@@ -117,25 +139,39 @@ mod tests {
}

#[test]
fn try_verify_succeeds_with_same_content() -> Fallible<()> {
fn verify_content_ok() -> Fallible<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn verify_content_ok() -> Fallible<()> {
fn verify_succeeds_with_same_content() -> Fallible<()> {

so that we keep in line with verify_fails_with_different_content

@vrutkovs
Copy link
Contributor

vrutkovs commented Feb 9, 2022

Looks good! Lets add some unit tests - i.e. vrutkovs@325e87b

@anti-social
Copy link
Contributor Author

anti-social commented Feb 9, 2022

Looks good! Lets add some unit tests - i.e. vrutkovs@325e87b

Oh, thanks. Yesterday also wanted to add tests but didn't find out why network tests failed.

@vrutkovs
Copy link
Contributor

Network tests are passing, but in Github Actions we get 429 from quay. Investigating this in #222

@anti-social
Copy link
Contributor Author

anti-social commented Feb 18, 2022

@vrutkovs We want to display a progress bar while downloading a layer. At the moment we cannot do that as there is no api to know layer's size. I suggest to slightly change a fetching blob api like following:

let blob_resp = dkclient.get_blob_response().await?;
let blob_size = blob_resp.size();
let blob_stream = blob_resp.stream();

What do you think about it?

@vrutkovs
Copy link
Contributor

Sure, that looks useful

@anti-social anti-social force-pushed the blob-stream branch 2 times, most recently from 8d4acca to 6bb2547 Compare May 9, 2022 17:29
@anti-social
Copy link
Contributor Author

Implemented getting blob size when using stream api.

@vrutkovs vrutkovs mentioned this pull request Jul 7, 2022
@vrutkovs
Copy link
Contributor

vrutkovs commented Jul 8, 2022

This looks great, thank you! Lets merge this now and adjust later if necessary

@vrutkovs vrutkovs merged commit 86f080f into camallo:master Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants