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

moved ReadAll and related functions to package Content #245

Merged
merged 9 commits into from
Jul 22, 2022
Merged

moved ReadAll and related functions to package Content #245

merged 9 commits into from
Jul 22, 2022

Conversation

wangxiaoxuan273
Copy link
Contributor

Signed-off-by: wangxiaoxuan273 [email protected]

Resolves #128

content/utils.go Outdated Show resolved Hide resolved
content/utils.go Show resolved Hide resolved
content/utils_test.go Outdated Show resolved Hide resolved
content/utils_test.go Outdated Show resolved Hide resolved
content/utils_test.go Show resolved Hide resolved
content/utils.go Outdated Show resolved Hide resolved
@Wwwsylvia
Copy link
Member

Can we also update the examples using io.ReadAll?

@wangxiaoxuan273
Copy link
Contributor Author

I'll open another pr to replace io.ReadAll.

internal/ioutil/io.go Outdated Show resolved Hide resolved
content/utils_test.go Outdated Show resolved Hide resolved
content/utils.go Outdated Show resolved Hide resolved
content/utils.go Outdated Show resolved Hide resolved
content/utils_test.go Outdated Show resolved Hide resolved
content/utils_test.go Outdated Show resolved Hide resolved
content/utils_test.go Show resolved Hide resolved
content/utils.go Outdated Show resolved Hide resolved
Signed-off-by: wangxiaoxuan273 <[email protected]>
Signed-off-by: wangxiaoxuan273 <[email protected]>
Signed-off-by: wangxiaoxuan273 <[email protected]>
Signed-off-by: wangxiaoxuan273 <[email protected]>
verifier := desc.Digest.Verifier()
r = io.TeeReader(r, verifier)
_, err := io.ReadFull(r, buf)
// verify the size of the read content

Choose a reason for hiding this comment

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

Does the comment relate to the next line code?

Copy link
Contributor Author

@wangxiaoxuan273 wangxiaoxuan273 Jul 22, 2022

Choose a reason for hiding this comment

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

Yes. The check is done by checking the err value returned by ReadAll() and EnsureEOF().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted this line of comment to avoid confusions.

Choose a reason for hiding this comment

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

i see, I feel it might be better to move it above _, err := io.ReadFull(r, buf) and we can put it with err check together in the if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed accordingly.

content/utils.go Show resolved Hide resolved
Signed-off-by: wangxiaoxuan273 <[email protected]>
Copy link
Member

@Wwwsylvia Wwwsylvia left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: wangxiaoxuan273 <[email protected]>
@Wwwsylvia Wwwsylvia merged commit 97a9c43 into oras-project:main Jul 22, 2022
@wangxiaoxuan273 wangxiaoxuan273 deleted the promote branch July 22, 2022 08:44
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.

Promote method internal/ioutil.ReadAll to package content
4 participants