summaryrefslogtreecommitdiffhomepage
path: root/tools/issue_reviver
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2020-05-14 14:00:52 -0700
committergVisor bot <gvisor-bot@google.com>2020-05-14 14:02:43 -0700
commitf589a85889c815cebac624122aebe14c8263a574 (patch)
tree5d863eaf8fb897f10cfd8cd68a98427d0af34229 /tools/issue_reviver
parentbdf7bb71d2bb8c6f4bcef9bdc590f01a9dc1cd64 (diff)
Run issue_reviver via GitHub.
PiperOrigin-RevId: 311600872
Diffstat (limited to 'tools/issue_reviver')
-rw-r--r--tools/issue_reviver/main.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/issue_reviver/main.go b/tools/issue_reviver/main.go
index 4256f5a6c..47c796b8a 100644
--- a/tools/issue_reviver/main.go
+++ b/tools/issue_reviver/main.go
@@ -20,6 +20,7 @@ import (
"fmt"
"io/ioutil"
"os"
+ "strings"
"gvisor.dev/gvisor/tools/issue_reviver/github"
"gvisor.dev/gvisor/tools/issue_reviver/reviver"
@@ -35,14 +36,22 @@ var (
// Keep the options simple for now. Supports only a single path and repo.
func init() {
- flag.StringVar(&owner, "owner", "google", "Github project org/owner to look for issues")
- flag.StringVar(&repo, "repo", "gvisor", "Github repo to look for issues")
+ flag.StringVar(&owner, "owner", "", "Github project org/owner to look for issues")
+ flag.StringVar(&repo, "repo", "", "Github repo to look for issues")
flag.StringVar(&tokenFile, "oauth-token-file", "", "Path to file containing the OAUTH token to be used as credential to github")
- flag.StringVar(&path, "path", "", "Path to scan for TODOs")
+ flag.StringVar(&path, "path", ".", "Path to scan for TODOs")
flag.BoolVar(&dryRun, "dry-run", false, "If set to true, no changes are made to issues")
}
func main() {
+ // Set defaults from the environment.
+ repository := os.Getenv("GITHUB_REPOSITORY")
+ if parts := strings.SplitN(repository, "/", 2); len(parts) == 2 {
+ owner = parts[0]
+ repo = parts[1]
+ }
+
+ // Parse flags.
flag.Parse()
// Check for mandatory parameters.
@@ -62,8 +71,10 @@ func main() {
os.Exit(1)
}
- // Token is passed as a file so it doesn't show up in command line arguments.
- var token string
+ // The access token may be passed as a file so it doesn't show up in
+ // command line arguments. It also may be provided through the
+ // environment to faciliate use through GitHub's CI system.
+ token := os.Getenv("GITHUB_TOKEN")
if len(tokenFile) != 0 {
bytes, err := ioutil.ReadFile(tokenFile)
if err != nil {