diff options
Diffstat (limited to 'bridge/gitlab/config.go')
-rw-r--r-- | bridge/gitlab/config.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/bridge/gitlab/config.go b/bridge/gitlab/config.go index dfac4c54..3496b4a3 100644 --- a/bridge/gitlab/config.go +++ b/bridge/gitlab/config.go @@ -32,7 +32,7 @@ func (g *Gitlab) ValidParams() map[string]interface{} { } } -func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (core.Configuration, error) { +func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams, interactive bool) (core.Configuration, error) { var err error var baseUrl string @@ -40,6 +40,9 @@ func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor case params.BaseURL != "": baseUrl = params.BaseURL default: + if !interactive { + return nil, fmt.Errorf("Non-interactive-mode is active. Please specify the gitlab instance URL via the --base-url option.") + } baseUrl, err = input.PromptDefault("Gitlab server URL", "URL", defaultBaseURL, input.Required, input.IsURL) if err != nil { return nil, errors.Wrap(err, "base url prompt") @@ -54,6 +57,9 @@ func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor projectURL = params.URL default: // terminal prompt + if !interactive { + return nil, fmt.Errorf("Non-interactive-mode is active. Please specify the gitlab project URL via the --url option.") + } projectURL, err = promptProjectURL(repo, baseUrl) if err != nil { return nil, errors.Wrap(err, "url prompt") @@ -89,6 +95,9 @@ func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor cred = token default: if params.Login == "" { + if !interactive { + return nil, fmt.Errorf("Non-interactive-mode is active. Please specify the login name via the --login option.") + } // TODO: validate username login, err = input.Prompt("Gitlab login", "login", input.Required) } else { @@ -98,6 +107,9 @@ func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor if err != nil { return nil, err } + if !interactive { + return nil, fmt.Errorf("Non-interactive-mode is active. Please specify the access token via the --token option.") + } cred, err = promptTokenOptions(repo, login, baseUrl) if err != nil { return nil, err |