aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/gitlab
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-08-21 14:24:48 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-08-31 23:02:20 +0200
commit0381400bfda16f910ca87b0258ddda1c1732fbc7 (patch)
tree54a271f43bafbbc238e2fc26bb6fa67d6403c4af /bridge/gitlab
parentc7792a5d1279a92c8d0caf67a0cf688cc9e32e09 (diff)
downloadgit-bug-0381400bfda16f910ca87b0258ddda1c1732fbc7.tar.gz
commands: read token from stdin in bridge configuration
bridge: improve bridge config validation
Diffstat (limited to 'bridge/gitlab')
-rw-r--r--bridge/gitlab/config.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/bridge/gitlab/config.go b/bridge/gitlab/config.go
index 15172871..d1d85030 100644
--- a/bridge/gitlab/config.go
+++ b/bridge/gitlab/config.go
@@ -20,7 +20,7 @@ var (
ErrBadProjectURL = errors.New("bad project url")
)
-func (*Gitlab) Configure(repo repository.RepoCommon, params core.BridgeParams) (core.Configuration, error) {
+func (g *Gitlab) Configure(repo repository.RepoCommon, params core.BridgeParams) (core.Configuration, error) {
if params.Project != "" {
fmt.Println("warning: --project is ineffective for a gitlab bridge")
}
@@ -33,6 +33,10 @@ func (*Gitlab) Configure(repo repository.RepoCommon, params core.BridgeParams) (
var url string
var token string
+ if params.Token != "" && params.URL == "" {
+ return nil, fmt.Errorf("you must provide a project URL to configure this bridge with a token")
+ }
+
// get project url
if params.URL != "" {
url = params.URL
@@ -71,10 +75,15 @@ func (*Gitlab) Configure(repo repository.RepoCommon, params core.BridgeParams) (
conf[keyToken] = token
conf[core.KeyTarget] = target
+ err = g.ValidateConfig(conf)
+ if err != nil {
+ return nil, err
+ }
+
return conf, nil
}
-func (*Gitlab) ValidateConfig(conf core.Configuration) error {
+func (g *Gitlab) ValidateConfig(conf core.Configuration) error {
if v, ok := conf[core.KeyTarget]; !ok {
return fmt.Errorf("missing %s key", core.KeyTarget)
} else if v != target {