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

Remove additional check if digester is available #2316

Closed

Conversation

saschagrunert
Copy link
Member

expectedDigest.Validate() already calls the Available() method and checks if the digest is possible or not. Therefore we can remove the additional/impossible double check for that.

Ref: https://github.com/opencontainers/go-digest/blob/429d0316a/digest.go#L111-L116

Follow-up on #2312

`expectedDigest.Validate()` already calls the `Available()` method and
checks if the digest is possible or not. Therefore we can remove the
additional/impossible double check for that.

Ref: https://github.com/opencontainers/go-digest/blob/429d0316a/digest.go#L111-L116

Signed-off-by: Sascha Grunert <[email protected]>
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

You’re right that, as implemented now, this check is redundant.

OTOH Validate() does not document that it checks for availability (and, IMHO, it’s a bit surprising that it does so), and when calling Digester() on an unavailable algorithm panics, I think the extra check here is somewhat warranted.

So I’d prefer keeping the code as is.

@saschagrunert
Copy link
Member Author

Sounds good, thank you!

@saschagrunert saschagrunert deleted the digester-available branch February 28, 2024 11:40
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