@ -19,8 +19,8 @@ import (
urlhelper "github.com/hashicorp/go-getter/helper/url"
)
// f ileChecksum helps verifying the checksum for a file.
type f ileChecksum struct {
// F ileChecksum helps verifying the checksum for a file.
type F ileChecksum 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 * f ileChecksum) checksum ( source string ) error {
func ( c * F ileChecksum) 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 f ileChecksum based on the 'checksum'
// extractChecksum will return a F ileChecksum based on the 'checksum'
// parameter of u.
// ex:
// http://hashicorp.com/terraform?checksum=<checksumValue>
@ -93,7 +93,7 @@ func (c *fileChecksum) checksum(source string) error {
// <checksum> *file2
//
// see parseChecksumLine for more detail on checksum file parsing
func ( c * Client ) extractChecksum ( u * url . URL ) ( * f ileChecksum, error ) {
func ( c * Client ) extractChecksum ( u * url . URL ) ( * F ileChecksum, error ) {
q := u . Query ( )
v := q . Get ( "checksum" )
@ -115,14 +115,14 @@ func (c *Client) extractChecksum(u *url.URL) (*fileChecksum, error) {
switch checksumType {
case "file" :
return c . c hecksumFromFile( checksumValue , u )
return c . C hecksumFromFile( checksumValue , u )
default :
return newChecksumFromType ( checksumType , checksumValue , filepath . Base ( u . EscapedPath ( ) ) )
}
}
func newChecksum ( checksumValue , filename string ) ( * f ileChecksum, error ) {
c := & f ileChecksum{
func newChecksum ( checksumValue , filename string ) ( * F ileChecksum, error ) {
c := & F ileChecksum{
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 ) ( * f ileChecksum, error ) {
func newChecksumFromType ( checksumType , checksumValue , filename string ) ( * F ileChecksum, 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 ) ( * f ileChecksum, error ) {
func newChecksumFromValue ( checksumValue , filename string ) ( * F ileChecksum, 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 f ileChecksums found in file
// ChecksumFromFile will return all the F ileChecksums found in file
//
// checksums FromFile will try to guess the hashing algorithm based on content
// Checksum FromFile will try to guess the hashing algorithm based on content
// of checksum file
//
// checksums FromFile will only return checksums for files that match file
// Checksum FromFile will only return checksums for files that match file
// behind src
func ( c * Client ) c hecksumFromFile( checksumFile string , src * url . URL ) ( * f ileChecksum, error ) {
func ( c * Client ) C hecksumFromFile( checksumFile string , src * url . URL ) ( * F ileChecksum, 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 ) ( * f ileChecksum, error ) {
func parseChecksumLine ( line string ) ( * F ileChecksum, error ) {
parts := strings . Fields ( line )
switch len ( parts ) {