@@ -33,17 +33,21 @@ type Env struct {
33
33
// Platform is our current platform
34
34
Platform versions.PlatformItem
35
35
36
- // VerifiySum indicates whether or not we should run checksums.
36
+ // VerifySum indicates whether we should run checksums.
37
37
VerifySum bool
38
- // NoDownload forces us to not contact GCS, looking only
39
- // at local files instead.
38
+ // NoDownload forces us to not contact GCS or download the index via HTTP,
39
+ // looking only at local files instead.
40
40
NoDownload bool
41
41
// ForceDownload forces us to ignore local files and always
42
- // contact GCS & re-download.
42
+ // contact GCS or download the index via HTTP & re-download.
43
43
ForceDownload bool
44
44
45
- // Client is our remote client for contacting GCS.
46
- Client * remote.Client
45
+ // UseGCS signals if the GCS client is used.
46
+ UseGCS bool
47
+
48
+ // Client is our remote client for contacting GCS or
49
+ // to download the index via HTTP.
50
+ Client remote.Client
47
51
48
52
// Log allows us to log.
49
53
Log logr.Logger
@@ -133,7 +137,7 @@ func (e *Env) ListVersions(ctx context.Context) {
133
137
}
134
138
135
139
// LatestVersion returns the latest version matching our version selector and
136
- // platform from the remote server, with the correspoding checksum for later
140
+ // platform from the remote server, with the corresponding checksum for later
137
141
// use as well.
138
142
func (e * Env ) LatestVersion (ctx context.Context ) (versions.Concrete , versions.PlatformItem ) {
139
143
vers , err := e .Client .ListVersions (ctx )
@@ -193,7 +197,7 @@ func (e *Env) ExistsAndValid() bool {
193
197
//
194
198
// If necessary, it will enumerate on-disk and remote versions to accomplish
195
199
// this, finding a version that matches our version selector and platform.
196
- // It will always yield a concrete version, it *may* yield a concrete platorm
200
+ // It will always yield a concrete version, it *may* yield a concrete platform
197
201
// as well.
198
202
func (e * Env ) EnsureVersionIsSet (ctx context.Context ) {
199
203
if e .Version .AsConcrete () != nil {
@@ -247,13 +251,13 @@ func (e *Env) EnsureVersionIsSet(ctx context.Context) {
247
251
248
252
// if we're not forcing a download, and we have a newer local version, just use that
249
253
if ! e .ForceDownload && localVer != nil && localVer .NewerThan (serverVer ) {
250
- e .Platform .Platform = localPlat // update our data with md5
254
+ e .Platform .Platform = localPlat // update our data with hash
251
255
e .Version .MakeConcrete (* localVer )
252
256
return
253
257
}
254
258
255
259
// otherwise, use the new version from the server
256
- e .Platform = platform // update our data with md5
260
+ e .Platform = platform // update our data with hash
257
261
e .Version .MakeConcrete (serverVer )
258
262
}
259
263
@@ -266,13 +270,13 @@ func (e *Env) Fetch(ctx context.Context) {
266
270
log := e .Log .WithName ("fetch" )
267
271
268
272
// if we didn't just fetch it, grab the sum to verify
269
- if e .VerifySum && e .Platform .MD5 == "" {
273
+ if e .VerifySum && e .Platform .Hash == nil {
270
274
if err := e .Client .FetchSum (ctx , * e .Version .AsConcrete (), & e .Platform ); err != nil {
271
- ExitCause (2 , err , "unable to fetch checksum for requested version" )
275
+ ExitCause (2 , err , "unable to fetch hash for requested version" )
272
276
}
273
277
}
274
278
if ! e .VerifySum {
275
- e .Platform .MD5 = "" // skip verification
279
+ e .Platform .Hash = nil // skip verification
276
280
}
277
281
278
282
var packedPath string
@@ -287,7 +291,7 @@ func (e *Env) Fetch(ctx context.Context) {
287
291
}
288
292
})
289
293
290
- archiveOut , err := e .FS .TempFile ("" , "*-" + e .Platform .ArchiveName (* e .Version .AsConcrete ()))
294
+ archiveOut , err := e .FS .TempFile ("" , "*-" + e .Platform .ArchiveName (e . UseGCS , * e .Version .AsConcrete ()))
291
295
if err != nil {
292
296
ExitCause (2 , err , "unable to open file to write downloaded archive to" )
293
297
}
@@ -365,8 +369,8 @@ func (e *Env) PrintInfo(printFmt PrintFormat) {
365
369
case PrintOverview :
366
370
fmt .Fprintf (e .Out , "Version: %s\n " , e .Version )
367
371
fmt .Fprintf (e .Out , "OS/Arch: %s\n " , e .Platform )
368
- if e .Platform .MD5 != "" {
369
- fmt .Fprintf (e .Out , "md5 : %s\n " , e .Platform .MD5 )
372
+ if e .Platform .Hash != nil {
373
+ fmt .Fprintf (e .Out , "%s : %s\n " , e .Platform .Hash . Type , e . Platform . Hash . Value )
370
374
}
371
375
fmt .Fprintf (e .Out , "Path: %s\n " , path )
372
376
case PrintPath :
@@ -409,7 +413,7 @@ func (e *Env) Sideload(ctx context.Context, input io.Reader) {
409
413
}
410
414
411
415
var (
412
- // expectedExectuables are the executables that are checked in PathMatches
416
+ // expectedExecutables are the executables that are checked in PathMatches
413
417
// for non-store paths.
414
418
expectedExecutables = []string {
415
419
"kube-apiserver" ,
@@ -458,7 +462,7 @@ func (e *Env) PathMatches(value string) bool {
458
462
}
459
463
460
464
// versionFromPathName checks if the given path's last component looks like one
461
- // of our versions, and, if so, what version it represents. If succesfull ,
465
+ // of our versions, and, if so, what version it represents. If successful ,
462
466
// it'll set version and platform, and return true. Otherwise it returns
463
467
// false.
464
468
func (e * Env ) versionFromPathName (value string ) bool {
0 commit comments