@@ -33,17 +33,21 @@ type Env struct {
3333 // Platform is our current platform
3434 Platform versions.PlatformItem
3535
36- // VerifiySum indicates whether or not we should run checksums.
36+ // VerifySum indicates whether we should run checksums.
3737 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.
4040 NoDownload bool
4141 // 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.
4343 ForceDownload bool
4444
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
4751
4852 // Log allows us to log.
4953 Log logr.Logger
@@ -133,7 +137,7 @@ func (e *Env) ListVersions(ctx context.Context) {
133137}
134138
135139// 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
137141// use as well.
138142func (e * Env ) LatestVersion (ctx context.Context ) (versions.Concrete , versions.PlatformItem ) {
139143 vers , err := e .Client .ListVersions (ctx )
@@ -193,7 +197,7 @@ func (e *Env) ExistsAndValid() bool {
193197//
194198// If necessary, it will enumerate on-disk and remote versions to accomplish
195199// 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
197201// as well.
198202func (e * Env ) EnsureVersionIsSet (ctx context.Context ) {
199203 if e .Version .AsConcrete () != nil {
@@ -247,13 +251,13 @@ func (e *Env) EnsureVersionIsSet(ctx context.Context) {
247251
248252 // if we're not forcing a download, and we have a newer local version, just use that
249253 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
251255 e .Version .MakeConcrete (* localVer )
252256 return
253257 }
254258
255259 // 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
257261 e .Version .MakeConcrete (serverVer )
258262}
259263
@@ -266,13 +270,13 @@ func (e *Env) Fetch(ctx context.Context) {
266270 log := e .Log .WithName ("fetch" )
267271
268272 // 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 {
270274 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" )
272276 }
273277 }
274278 if ! e .VerifySum {
275- e .Platform .MD5 = "" // skip verification
279+ e .Platform .Hash = nil // skip verification
276280 }
277281
278282 var packedPath string
@@ -287,7 +291,7 @@ func (e *Env) Fetch(ctx context.Context) {
287291 }
288292 })
289293
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 ()))
291295 if err != nil {
292296 ExitCause (2 , err , "unable to open file to write downloaded archive to" )
293297 }
@@ -365,8 +369,8 @@ func (e *Env) PrintInfo(printFmt PrintFormat) {
365369 case PrintOverview :
366370 fmt .Fprintf (e .Out , "Version: %s\n " , e .Version )
367371 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 )
370374 }
371375 fmt .Fprintf (e .Out , "Path: %s\n " , path )
372376 case PrintPath :
@@ -409,7 +413,7 @@ func (e *Env) Sideload(ctx context.Context, input io.Reader) {
409413}
410414
411415var (
412- // expectedExectuables are the executables that are checked in PathMatches
416+ // expectedExecutables are the executables that are checked in PathMatches
413417 // for non-store paths.
414418 expectedExecutables = []string {
415419 "kube-apiserver" ,
@@ -458,7 +462,7 @@ func (e *Env) PathMatches(value string) bool {
458462}
459463
460464// 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 ,
462466// it'll set version and platform, and return true. Otherwise it returns
463467// false.
464468func (e * Env ) versionFromPathName (value string ) bool {
0 commit comments