Skip to content

Commit

Permalink
Fixed PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ckannon committed May 9, 2022
1 parent 3f458b4 commit 6ed07b9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/minikube/bootstrapper/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,23 @@ func componentImage(name string, v semver.Version, mirror string) string {
func findLatestTagFromRepository(url string, lastKnownGood string) string {
client := &http.Client{}
req, err := http.NewRequest("GET", url, nil)

errorMsg := fmt.Sprintf("Failed to get latest image version for %s, reverting to version %s.", url, lastKnownGood)
if err != nil {
klog.Infof("Failed to get latest image version for %s, reverting to version %s\n", url, lastKnownGood)
klog.Warningf("%s Error %v", errorMsg, err)
return lastKnownGood
}

resp, err := client.Do(req)

if err != nil || resp.StatusCode != http.StatusOK {
klog.Infof("Failed to get latest image version for %s, reverting to version %s\n", url, lastKnownGood)
klog.Warningf("%s Error %v", errorMsg, err)
return lastKnownGood
}
defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
if err != nil {
klog.Infof("Failed to read latest image version for %s, reverting to version %s\n", url, lastKnownGood)
klog.Warningf("%s Error %v", errorMsg, err)
return lastKnownGood
}

Expand All @@ -108,7 +108,7 @@ func findLatestTagFromRepository(url string, lastKnownGood string) string {
tags := TagsResponse{}
err = json.Unmarshal(body, &tags)
if err != nil || len(tags.Tags) < 1 {
klog.Infof("Failed to read latest image version for %s, reverting to version %s\n", url, lastKnownGood)
klog.Warningf("%s Error %v", errorMsg, err)
return lastKnownGood
}
lastTagNum := len(tags.Tags) - 1
Expand Down

0 comments on commit 6ed07b9

Please sign in to comment.