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. |
| } | ||
|
|
||
| func parseDigestValidator(digest string) (digestValidator, error) { | ||
| alg := digest[:strings.Index(digest, ":")] |
There was a problem hiding this comment.
There might be an "index out of range" issue if digest does not contain a :.
| if v, ok := validatorCtors[alg]; ok { | ||
| return v(), nil | ||
| } else { | ||
| return nil, ErrDigestAlgNotSupported | ||
| } |
There was a problem hiding this comment.
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.
It applies to all occurrences in this file.
| 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.
Just curious if calculator can be reused in another process or not.
There was a problem hiding this comment.
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