@@ -19,8 +19,8 @@ import (
19
19
urlhelper "github.com/hashicorp/go-getter/helper/url"
20
20
)
21
21
22
- // fileChecksum helps verifying the checksum for a file.
23
- type fileChecksum struct {
22
+ // FileChecksum helps verifying the checksum for a file.
23
+ type FileChecksum struct {
24
24
Type string
25
25
Hash hash.Hash
26
26
Value []byte
@@ -50,7 +50,7 @@ func (cerr *ChecksumError) Error() string {
50
50
51
51
// checksum is a simple method to compute the checksum of a source file
52
52
// and compare it to the given expected value.
53
- func (c * fileChecksum ) checksum (source string ) error {
53
+ func (c * FileChecksum ) checksum (source string ) error {
54
54
f , err := os .Open (source )
55
55
if err != nil {
56
56
return fmt .Errorf ("Failed to open file for checksum: %s" , err )
@@ -74,7 +74,7 @@ func (c *fileChecksum) checksum(source string) error {
74
74
return nil
75
75
}
76
76
77
- // extractChecksum will return a fileChecksum based on the 'checksum'
77
+ // extractChecksum will return a FileChecksum based on the 'checksum'
78
78
// parameter of u.
79
79
// ex:
80
80
// http://hashicorp.com/terraform?checksum=<checksumValue>
@@ -93,7 +93,7 @@ func (c *fileChecksum) checksum(source string) error {
93
93
// <checksum> *file2
94
94
//
95
95
// see parseChecksumLine for more detail on checksum file parsing
96
- func (c * Client ) extractChecksum (u * url.URL ) (* fileChecksum , error ) {
96
+ func (c * Client ) extractChecksum (u * url.URL ) (* FileChecksum , error ) {
97
97
q := u .Query ()
98
98
v := q .Get ("checksum" )
99
99
@@ -115,14 +115,14 @@ func (c *Client) extractChecksum(u *url.URL) (*fileChecksum, error) {
115
115
116
116
switch checksumType {
117
117
case "file" :
118
- return c .checksumFromFile (checksumValue , u )
118
+ return c .ChecksumFromFile (checksumValue , u )
119
119
default :
120
120
return newChecksumFromType (checksumType , checksumValue , filepath .Base (u .EscapedPath ()))
121
121
}
122
122
}
123
123
124
- func newChecksum (checksumValue , filename string ) (* fileChecksum , error ) {
125
- c := & fileChecksum {
124
+ func newChecksum (checksumValue , filename string ) (* FileChecksum , error ) {
125
+ c := & FileChecksum {
126
126
Filename : filename ,
127
127
}
128
128
var err error
@@ -133,7 +133,7 @@ func newChecksum(checksumValue, filename string) (*fileChecksum, error) {
133
133
return c , nil
134
134
}
135
135
136
- func newChecksumFromType (checksumType , checksumValue , filename string ) (* fileChecksum , error ) {
136
+ func newChecksumFromType (checksumType , checksumValue , filename string ) (* FileChecksum , error ) {
137
137
c , err := newChecksum (checksumValue , filename )
138
138
if err != nil {
139
139
return nil , err
@@ -157,7 +157,7 @@ func newChecksumFromType(checksumType, checksumValue, filename string) (*fileChe
157
157
return c , nil
158
158
}
159
159
160
- func newChecksumFromValue (checksumValue , filename string ) (* fileChecksum , error ) {
160
+ func newChecksumFromValue (checksumValue , filename string ) (* FileChecksum , error ) {
161
161
c , err := newChecksum (checksumValue , filename )
162
162
if err != nil {
163
163
return nil , err
@@ -183,14 +183,14 @@ func newChecksumFromValue(checksumValue, filename string) (*fileChecksum, error)
183
183
return c , nil
184
184
}
185
185
186
- // checksumsFromFile will return all the fileChecksums found in file
186
+ // ChecksumFromFile will return all the FileChecksums found in file
187
187
//
188
- // checksumsFromFile will try to guess the hashing algorithm based on content
188
+ // ChecksumFromFile will try to guess the hashing algorithm based on content
189
189
// of checksum file
190
190
//
191
- // checksumsFromFile will only return checksums for files that match file
191
+ // ChecksumFromFile will only return checksums for files that match file
192
192
// behind src
193
- func (c * Client ) checksumFromFile (checksumFile string , src * url.URL ) (* fileChecksum , error ) {
193
+ func (c * Client ) ChecksumFromFile (checksumFile string , src * url.URL ) (* FileChecksum , error ) {
194
194
checksumFileURL , err := urlhelper .Parse (checksumFile )
195
195
if err != nil {
196
196
return nil , err
@@ -286,7 +286,7 @@ func (c *Client) checksumFromFile(checksumFile string, src *url.URL) (*fileCheck
286
286
// of a line.
287
287
// for BSD type sums parseChecksumLine guesses the hashing algorithm
288
288
// by checking the length of the checksum.
289
- func parseChecksumLine (line string ) (* fileChecksum , error ) {
289
+ func parseChecksumLine (line string ) (* FileChecksum , error ) {
290
290
parts := strings .Fields (line )
291
291
292
292
switch len (parts ) {
0 commit comments