aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github/config.go
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-09-02 09:24:53 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-09-02 09:44:00 +0200
commitf3d8da10750d58fce482042cff87455a1e6f36e0 (patch)
tree5018a7356afa8ade6a69eb8767aa7a3439aa01da /bridge/github/config.go
parent46f957344499863c97a20d34cf8ba078d3245c3a (diff)
downloadgit-bug-f3d8da10750d58fce482042cff87455a1e6f36e0.tar.gz
bridge/core: add tokenStdin field to bridgeParams
commands: move tokenStdin handling logic to bridge.Configure
Diffstat (limited to 'bridge/github/config.go')
-rw-r--r--bridge/github/config.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/bridge/github/config.go b/bridge/github/config.go
index bc4911e0..16abfa09 100644
--- a/bridge/github/config.go
+++ b/bridge/github/config.go
@@ -45,7 +45,7 @@ func (g *Github) Configure(repo repository.RepoCommon, params core.BridgeParams)
var owner string
var project string
- if params.Token != "" &&
+ if (params.Token != "" || params.TokenStdin) &&
(params.URL == "" && (params.Project == "" || params.Owner == "")) {
return nil, fmt.Errorf("you must provide a project URL or Owner/Name to configure this bridge with a token")
}
@@ -91,6 +91,13 @@ func (g *Github) Configure(repo repository.RepoCommon, params core.BridgeParams)
if params.Token != "" {
token = params.Token
+ } else if params.TokenStdin {
+ reader := bufio.NewReader(os.Stdin)
+ token, err = reader.ReadString('\n')
+ if err != nil {
+ return nil, fmt.Errorf("reading from stdin: %v", err)
+ }
+ token = strings.TrimSuffix(token, "\n")
} else {
token, err = promptTokenOptions(owner, project)
if err != nil {