From 0061979e3ee9e575d1157eb4e9af673718f7416a Mon Sep 17 00:00:00 2001 From: Moto Ishizawa Date: Mon, 3 Feb 2020 17:02:27 +0900 Subject: [PATCH] Add '-github-token' flag --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 7c833479..97b06681 100644 --- a/main.go +++ b/main.go @@ -58,6 +58,7 @@ func main() { runnerImage string dockerImage string + ghToken string ) flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.") @@ -65,11 +66,14 @@ func main() { "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.") flag.StringVar(&runnerImage, "runner-image", defaultRunnerImage, "The image name of self-hosted runner container.") flag.StringVar(&dockerImage, "docker-image", defaultDockerImage, "The image name of docker sidecar container.") + flag.StringVar(&ghToken, "github-token", "", "The access token of GitHub.") flag.Parse() - ghToken := os.Getenv("GITHUB_TOKEN") if ghToken == "" { - fmt.Fprintln(os.Stderr, "Error: access token is not specified in the environment variable 'GITHUB_TOKEN'") + ghToken = os.Getenv("GITHUB_TOKEN") + } + if ghToken == "" { + fmt.Fprintln(os.Stderr, "Error: GitHub access token must be specified.") os.Exit(1) }