From 025d982698331f7db2c22e09119ff45c2231b669 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 27 Jun 2019 15:07:39 -0700 Subject: [PATCH] export fileChecksum and adjust comments to reflect new exported method name --- checksum.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/checksum.go b/checksum.go index 62ce758a5..eeccfea9d 100644 --- a/checksum.go +++ b/checksum.go @@ -19,8 +19,8 @@ import ( urlhelper "github.com/hashicorp/go-getter/helper/url" ) -// fileChecksum helps verifying the checksum for a file. -type fileChecksum struct { +// FileChecksum helps verifying the checksum for a file. +type FileChecksum struct { Type string Hash hash.Hash Value []byte @@ -50,7 +50,7 @@ func (cerr *ChecksumError) Error() string { // checksum is a simple method to compute the checksum of a source file // and compare it to the given expected value. -func (c *fileChecksum) checksum(source string) error { +func (c *FileChecksum) checksum(source string) error { f, err := os.Open(source) if err != nil { return fmt.Errorf("Failed to open file for checksum: %s", err) @@ -74,7 +74,7 @@ func (c *fileChecksum) checksum(source string) error { return nil } -// extractChecksum will return a fileChecksum based on the 'checksum' +// extractChecksum will return a FileChecksum based on the 'checksum' // parameter of u. // ex: // http://hashicorp.com/terraform?checksum= @@ -93,7 +93,7 @@ func (c *fileChecksum) checksum(source string) error { // *file2 // // see parseChecksumLine for more detail on checksum file parsing -func (c *Client) extractChecksum(u *url.URL) (*fileChecksum, error) { +func (c *Client) extractChecksum(u *url.URL) (*FileChecksum, error) { q := u.Query() v := q.Get("checksum") @@ -121,8 +121,8 @@ func (c *Client) extractChecksum(u *url.URL) (*fileChecksum, error) { } } -func newChecksum(checksumValue, filename string) (*fileChecksum, error) { - c := &fileChecksum{ +func newChecksum(checksumValue, filename string) (*FileChecksum, error) { + c := &FileChecksum{ Filename: filename, } var err error @@ -133,7 +133,7 @@ func newChecksum(checksumValue, filename string) (*fileChecksum, error) { return c, nil } -func newChecksumFromType(checksumType, checksumValue, filename string) (*fileChecksum, error) { +func newChecksumFromType(checksumType, checksumValue, filename string) (*FileChecksum, error) { c, err := newChecksum(checksumValue, filename) if err != nil { return nil, err @@ -157,7 +157,7 @@ func newChecksumFromType(checksumType, checksumValue, filename string) (*fileChe return c, nil } -func newChecksumFromValue(checksumValue, filename string) (*fileChecksum, error) { +func newChecksumFromValue(checksumValue, filename string) (*FileChecksum, error) { c, err := newChecksum(checksumValue, filename) if err != nil { return nil, err @@ -183,14 +183,14 @@ func newChecksumFromValue(checksumValue, filename string) (*fileChecksum, error) return c, nil } -// checksumsFromFile will return all the fileChecksums found in file +// ChecksumFromFile will return all the FileChecksums found in file // -// checksumsFromFile will try to guess the hashing algorithm based on content +// ChecksumFromFile will try to guess the hashing algorithm based on content // of checksum file // -// checksumsFromFile will only return checksums for files that match file +// ChecksumFromFile will only return checksums for files that match file // behind src -func (c *Client) ChecksumFromFile(checksumFile string, src *url.URL) (*fileChecksum, error) { +func (c *Client) ChecksumFromFile(checksumFile string, src *url.URL) (*FileChecksum, error) { checksumFileURL, err := urlhelper.Parse(checksumFile) if err != nil { return nil, err @@ -286,7 +286,7 @@ func (c *Client) ChecksumFromFile(checksumFile string, src *url.URL) (*fileCheck // of a line. // for BSD type sums parseChecksumLine guesses the hashing algorithm // by checking the length of the checksum. -func parseChecksumLine(line string) (*fileChecksum, error) { +func parseChecksumLine(line string) (*FileChecksum, error) { parts := strings.Fields(line) switch len(parts) {