Merge pull request #15744 from spowelljr/fixGoUpdate

CI: Skip updating golang hash file if version already exists
pull/15767/head
Medya Ghazizadeh 2023-01-31 17:41:56 -08:00 committed by GitHub
commit 8e85e7d710
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -217,6 +217,15 @@ func goVersions() (stable, stableMM, k8sVersion string, err error) {
}
func updateGoHashFile(version string) error {
hashFilePath := "../../../deploy/iso/minikube-iso/go.hash"
b, err := os.ReadFile(hashFilePath)
if err != nil {
return fmt.Errorf("failed to read hash file: %v", err)
}
if strings.Contains(string(b), version) {
klog.Infof("hash file already contains %q", version)
return nil
}
r, err := http.Get(fmt.Sprintf("https://dl.google.com/go/go%s.src.tar.gz.sha256", version))
if err != nil {
return fmt.Errorf("failed to download golang sha256 file: %v", err)
@ -226,7 +235,7 @@ func updateGoHashFile(version string) error {
if err != nil {
return fmt.Errorf("failed to read response body: %v", err)
}
f, err := os.OpenFile("../../../deploy/iso/minikube-iso/go.hash", os.O_APPEND|os.O_WRONLY, 0644)
f, err := os.OpenFile(hashFilePath, os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
return fmt.Errorf("failed to open go.hash file: %v", err)
}