-
Notifications
You must be signed in to change notification settings - Fork 246
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
go-get checksum file & guess checksum #136
Conversation
This comment has been minimized.
This comment has been minimized.
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.
Hey @azr, this is an interesting concept indeed, but I think we could possibly go about the hash detection in a much less complex way.
BSD formats notwithstanding, the hash should always be at the start of the file, and a hashed checksum is always going to be a static length depending on the algorithm:
You could probably just take the sum, decode it from hex, and then check its size to get the right algorithm, and also pull the right file out accounting for specific the mode modifiers.
I've left some notes regarding recommending a refactoring of the functionality so that both query and file parsing go down two explicit code paths - that should make this easier to read.
Let me know when you've had a chance to update!
Hey @vancluever ! |
Okay, there, this should be done. Tell me what you think |
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.
Hey @azr, looking a lot better, got some new comments to address, but fundamentally this is a great improvement!
checksum.go
Outdated
// | ||
// checksumsFromFile will only return checksums for files that match file | ||
// behind src | ||
func checksumFromFile(checksumFile string, src *url.URL) (*fileChecksum, 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.
Hmm, I think I answered the question that I had from the docs here... we should really try and see how we can ensure that the same getter that is used to fetch the file is used to fetch the checksums. As mentioned, this is important on the HTTP getter where a custom client or additional headers will be used.
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.
Okay, trying something 🙂 !
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 based on what I mentioned here, the client should probably just be passed in as a parameter to save having to apply several breaking changes to the code.
81c5385
to
c795398
Compare
Okay @vancluever I think this is better now, putting everything down methods/funcs had me cornered into a rabbit hole so instead I took a step back and put some code back/up in client.Get. I also made a This makes the body of Tell me what you think 🙂 |
Hello @vancluever, I updated this pull request to have the checksum create a copy of the client to download the checksum file. Like we decided. Notes: I also marked all convos as resolved for less clogging as this PR got huge. Thanks again for your patience. |
"io/ioutil" | ||
) | ||
|
||
func tmpFile(dir, pattern string) (string, 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 noticed that in testing references that there is already a tempFile
helper (with the "e"). This is a bit confusing and I think that one should be used instead if it's not functionally different. If it's in a test helper file, just move it to a common helper file (ie: this common.go
) so that it can be used in non-test code.
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.
PS: If it needs to be extended to return errors, that's fine too. Just the point being that we should avoid having two tempfile helpers.
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.
Okay, I simplified this... By adding a mustString
func. I hope this is good 🙂
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.
From what I can see, there's some other implementation details of tempFile
that were missed. I'll have a look over it again and see if I can just manually correct it.
…_parseChecksumLine so we test everything from one entrypoint
TestGetFile_checksum_from_file tests it's cases we better
…e the hash at the beginning of line in an unexpected format
…parallel" This reverts commit f01d3d0.
they don't happen in the wild.
…les instead * also avoid protocol to be matched from the query parameters
I just rebased this branch on master after #131 was merged 🙂 |
This reverts commit 7607f9c. The old test tempFile function is not general purpose and sets up a static file within a directory created by the tempDir helper. This functionality needs to be preserved, so the correct plan of action would be to preserve this functionality while moving the function name to another, logical name such as tempTestFile.
This renames the internal test tempFile function to tempTestFile. It also fixes some of the cleanup calls that were added - rather than deleting the static file created only, it deletes the directory, which is actually the specific temporary data created.
Okay, as mentioned, the old test This has now been corrected (you can see the changes in 6d796ed) and I'm just waiting for Travis to finish before merging. |
Hello,
This pr allows to checksum from a file; this should be the last needed feature for packer to be able to use go-getter 🙂
file_url?checksum=file:checksum_url