Skip to content

Commit

Permalink
Update hack/update/github.go
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Powell <[email protected]>
  • Loading branch information
ComradeProgrammer and spowelljr committed Aug 30, 2024
1 parent fa93c5a commit fa495bf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 4 additions & 1 deletion hack/preload-images/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"github.com/pkg/errors"
"k8s.io/klog/v2"
"k8s.io/minikube/hack/update"
"k8s.io/minikube/pkg/drivers/kic"
"k8s.io/minikube/pkg/drivers/kic/oci"
Expand Down Expand Up @@ -136,7 +137,9 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
k8sVer, _ := util.ParseKubernetesVersion(kubernetesVersion)
crictlVer, _ := util.ParseKubernetesVersion(crictlVersion)
return k8sVer.Major == crictlVer.Major && k8sVer.Minor == crictlVer.Minor
}); err == nil {
}); err != nil {
klog.Error("failed to get the newest version tag pf crictl from github")
} else {
crictlVersion = stable.Tag
}

Expand Down
7 changes: 5 additions & 2 deletions hack/update/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ func GHReleases(ctx context.Context, owner, repo string) (stable, latest, edge R
return GHReleasesWithCondition(ctx, owner, repo, nil)
}

// GHReleasesWithCondition returns greatest current stable release and greatest latest rc or beta pre-release from GitHub owner/repo repository whose version number satisfy the condition given in the parameter, and any error occurred.
// If latest pre-release version is lower than the current stable release, then it will return current stable release for both.
// GHReleasesWithCondition returns greatest current stable release and greatest
// latest rc or beta pre-release from GitHub owner/repo repository whose version
// number satisfy the condition given in the parameter, and any error occurred.
// If latest pre-release version is lower than the current stable release, then
// it will return current stable release for both.
func GHReleasesWithCondition(ctx context.Context, owner, repo string, condition func(string) bool) (stable, latest, edge Release, err error) {
ghc := github.NewClient(nil)

Expand Down
11 changes: 6 additions & 5 deletions pkg/minikube/download/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"path"
"runtime"

"k8s.io/minikube/pkg/util"
"github.com/blang/semver/v4"
"github.com/pkg/errors"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/util"
)

// DefaultKubeBinariesURL returns a URL to kube binaries
Expand Down Expand Up @@ -97,13 +97,14 @@ func CrictlBinary(k8sversion string, crictlVersion string) (string, error) {
klog.Infof("crictl found in cache: %s", targetPath)
return targetPath, nil
}
v, err := util.ParseKubernetesVersion(k8sversion)
if err != nil {
return "", err
}

// if we don't know the exact patch number of crictl then use 0.
// This definitely exists
if crictlVersion == "" {
v, err := util.ParseKubernetesVersion(k8sversion)
if err != nil {
return "", err
}
crictlVersion = fmt.Sprintf("v%d.%d.0", v.Major, v.Minor)
}
url := fmt.Sprintf(
Expand Down

0 comments on commit fa495bf

Please sign in to comment.