avoid conflict with the update package flags
parent
2c53bac3d7
commit
2433c7978c
|
@ -18,18 +18,18 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/google/go-github/v74/github"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/hack/update"
|
||||
)
|
||||
|
||||
// recentK8sVersions returns the most recent k8s version, usually around 100.
|
||||
func recentK8sVersions() ([]string, error) {
|
||||
const k8s = "kubernetes"
|
||||
ghc := update.GHClient()
|
||||
ghc := ghClient()
|
||||
list, _, err := ghc.Repositories.ListReleases(context.Background(), k8s, k8s, &github.ListOptions{PerPage: 100})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -45,3 +45,13 @@ func recentK8sVersions() ([]string, error) {
|
|||
klog.InfoS("Got releases", "releases", releases)
|
||||
return releases, nil
|
||||
}
|
||||
|
||||
// ghClient returns a GitHub client regardless of whether the GITHUB_TOKEN is set or not.
|
||||
// NOTE: do NOT use "k8s.io/minikube/hack/update" instead, as its flags will conflict with the ones from this package
|
||||
func ghClient() *github.Client {
|
||||
if os.Getenv("GITHUB_TOKEN") == "" {
|
||||
return github.NewClient(nil)
|
||||
}
|
||||
return github.NewClient(nil).WithAuthToken(os.Getenv("GITHUB_TOKEN"))
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue