mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Optionally use a github api token when compiling relase-notes
This commit is contained in:
parent
145386ae9e
commit
b6cd4bedaa
@ -24,19 +24,18 @@ function pop_dir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||||
|
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||||
|
|
||||||
if [[ -z "${1:-}" ]]; then
|
if [[ -z "${1:-}" ]]; then
|
||||||
echo "Usage: ${0} <pr-number>"
|
echo "Usage: ${0} <pr-number> [opts]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pushd . > /dev/null
|
pushd . > /dev/null
|
||||||
trap 'pop_dir' INT TERM EXIT
|
trap 'pop_dir' INT TERM EXIT
|
||||||
|
|
||||||
cd ${KUBE_ROOT}/contrib/release-notes
|
kube::golang::build_binaries contrib/release-notes
|
||||||
# TODO: vendor these dependencies, but using godep again will be annoying...
|
kube::golang::place_bins
|
||||||
GOPATH=$PWD go get github.com/google/go-github/github
|
releasenotes=$(kube::util::find-binary "release-notes")
|
||||||
GOPATH=$PWD go get github.com/google/go-querystring/query
|
"${releasenotes}" --last-release-pr=${1} ${@}
|
||||||
GOPATH=$PWD go build release-notes.go
|
|
||||||
./release-notes --last-release-pr=${1}
|
|
||||||
|
|
||||||
|
@ -18,24 +18,43 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
|
flag "github.com/spf13/pflag"
|
||||||
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var target = flag.Int("last-release-pr", 0, "The PR number of the last versioned release.")
|
var (
|
||||||
|
target int
|
||||||
|
token string
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flag.IntVar(&target, "last-release-pr", 0, "The PR number of the last versioned release.")
|
||||||
|
flag.StringVar(&token, "api-token", "", "Github api token for rate limiting. See https://developer.github.com/v3/#rate-limiting.")
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
// Automatically determine this from github.
|
// Automatically determine this from github.
|
||||||
if *target == 0 {
|
if target == 0 {
|
||||||
fmt.Printf("--last-release-pr is required.\n")
|
fmt.Printf("--last-release-pr is required.\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
var tc *http.Client
|
||||||
|
|
||||||
client := github.NewClient(nil)
|
if len(token) > 0 {
|
||||||
|
tc = oauth2.NewClient(
|
||||||
|
oauth2.NoContext,
|
||||||
|
oauth2.StaticTokenSource(
|
||||||
|
&oauth2.Token{AccessToken: token}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
client := github.NewClient(tc)
|
||||||
|
|
||||||
done := false
|
done := false
|
||||||
|
|
||||||
@ -62,7 +81,7 @@ func main() {
|
|||||||
if result.MergedAt == nil {
|
if result.MergedAt == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if *result.Number == *target {
|
if *result.Number == target {
|
||||||
done = true
|
done = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user