-
Notifications
You must be signed in to change notification settings - Fork 848
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
add digest validation utils and examples #20887
Conversation
@jhendrixMSFT @JeffreyRichter please help to review the digest validation utils. You could refer all example files for the usage. A brief explanation:
|
@JeffreyRichter The latest API view for |
I had just 1 comment about hash algorithms |
Thanks for the quick review. I've replied the comment. The hash algorithm is considered already. |
sdk/containers/azcontainerregistry/example_download_image_test.go
Outdated
Show resolved
Hide resolved
sdk/containers/azcontainerregistry/blob_custom_client_example_test.go
Outdated
Show resolved
Hide resolved
} | ||
|
||
func parseDigestValidator(digest string) (digestValidator, error) { | ||
alg := digest[:strings.Index(digest, ":")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be an "index out of range" issue if digest
does not contain a :
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix before GA.
if v, ok := validatorCtors[alg]; ok { | ||
return v(), nil | ||
} else { | ||
return nil, ErrDigestAlgNotSupported | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, you may want to read https://github.com/golang/go/wiki/CodeReviewComments#indent-error-flow to remove the else
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It applies to all occurrences in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix before GA.
end = size | ||
} | ||
chunkReader := io.NewSectionReader(f, current, end-current) | ||
uploadResp, err := blobClient.UploadChunk(context.TODO(), location, chunkReader, calculator, &azcontainerregistry.BlobClientUploadChunkOptions{RangeStart: to.Ptr(int32(current)), RangeEnd: to.Ptr(int32(end - 1))}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious if calculator
can be reused in another process or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The calculator will hold the hash calculation status, so one calculator for one upload. I'll added some doc to explain it before GA.
resolve: #20836