-
Notifications
You must be signed in to change notification settings - Fork 2
Add Tarsum Calculation during v2 Pull operation #9
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
Conversation
While the v2 pull operation is writing the body of the layer blob to disk it now computes the tarsum checksum of the archive before extracting it to the backend storage driver. If the checksum does not match that from the image manifest an error is raised. Also adds more debug logging to the pull operation and fixes existing test cases which were failing. Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
It passes the tests! I checked. |
// Create a new TarSum using the provided TarSum version+hash label. | ||
func NewTarSumForLabel(r io.Reader, disableCompression bool, label string) (TarSum, error) { | ||
parts := strings.SplitN(label, "+", 2) | ||
if len(parts) != 2 { |
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.
doesn't splitN force it to be 2
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.
nm I was wrong https://play.golang.org/p/JhWAqEM7Al if curious
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.
er, I think it's at most 2, per the docs:
n > 0: at most n substrings; the last substring will be the unsplit remainder.
lgtm |
@@ -39,6 +42,30 @@ func NewTarSumHash(r io.Reader, dc bool, v Version, tHash THash) (TarSum, error) | |||
return ts, err | |||
} | |||
|
|||
// Create a new TarSum using the provided TarSum version+hash label. | |||
func NewTarSumForLabel(r io.Reader, disableCompression bool, label string) (TarSum, error) { |
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.
I am not sure I am into this being a single function. I don't have a better suggestion at this time, so you can disregard my comment.
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.
I just added this to the tarsum package because there currently isn't a reverse lookup constructor >_>
LGTM! |
LGTM |
While the v2 pull operation is writing the body of the layer blob to disk
it now computes the tarsum checksum of the archive before extracting it to
the backend storage driver. If the checksum does not match that from the
image manifest an error is raised.
Also adds more debug logging to the pull operation and fixes existing test
cases which were failing.
Docker-DCO-1.1-Signed-off-by: Josh Hawn josh.hawn@docker.com (github: jlhawn)