aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/gitlab
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-01-03 13:53:59 +0100
committerMichael Muré <batolettre@gmail.com>2020-01-03 13:53:59 +0100
commit86b114ae7e0ff376c84381bdb0d466f0c1c11ad5 (patch)
tree7cb04a91c83a7dabb7a36bccd60be6dd2417fd20 /bridge/gitlab
parentd2ed6747e593e12c317d5191573d5d3460d72660 (diff)
downloadgit-bug-86b114ae7e0ff376c84381bdb0d466f0c1c11ad5.tar.gz
gitlab: proper token generation URL with custom base URL
Diffstat (limited to 'bridge/gitlab')
-rw-r--r--bridge/gitlab/config.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/bridge/gitlab/config.go b/bridge/gitlab/config.go
index 1f542d39..5e345b31 100644
--- a/bridge/gitlab/config.go
+++ b/bridge/gitlab/config.go
@@ -5,6 +5,7 @@ import (
"fmt"
"net/url"
"os"
+ "path"
"regexp"
"sort"
"strconv"
@@ -98,7 +99,7 @@ func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor
case params.TokenRaw != "":
cred = auth.NewToken(userId, params.TokenRaw, target)
default:
- cred, err = promptTokenOptions(repo, userId)
+ cred, err = promptTokenOptions(repo, userId, baseUrl)
if err != nil {
return nil, err
}
@@ -209,7 +210,7 @@ func validateBaseUrl(baseUrl string) (bool, error) {
return u.Scheme != "" && u.Host != "", nil
}
-func promptTokenOptions(repo repository.RepoConfig, userId entity.Id) (auth.Credential, error) {
+func promptTokenOptions(repo repository.RepoConfig, userId entity.Id, baseUrl string) (auth.Credential, error) {
for {
creds, err := auth.List(repo, auth.WithUserId(userId), auth.WithTarget(target), auth.WithKind(auth.KindToken))
if err != nil {
@@ -218,7 +219,7 @@ func promptTokenOptions(repo repository.RepoConfig, userId entity.Id) (auth.Cred
// if we don't have existing token, fast-track to the token prompt
if len(creds) == 0 {
- value, err := promptToken()
+ value, err := promptToken(baseUrl)
if err != nil {
return nil, err
}
@@ -260,7 +261,7 @@ func promptTokenOptions(repo repository.RepoConfig, userId entity.Id) (auth.Cred
switch index {
case 1:
- value, err := promptToken()
+ value, err := promptToken(baseUrl)
if err != nil {
return nil, err
}
@@ -271,8 +272,8 @@ func promptTokenOptions(repo repository.RepoConfig, userId entity.Id) (auth.Cred
}
}
-func promptToken() (string, error) {
- fmt.Println("You can generate a new token by visiting https://gitlab.com/profile/personal_access_tokens.")
+func promptToken(baseUrl string) (string, error) {
+ fmt.Printf("You can generate a new token by visiting %s.\n", path.Join(baseUrl, "profile/personal_access_tokens"))
fmt.Println("Choose 'Create personal access token' and set the necessary access scope for your repository.")
fmt.Println()
fmt.Println("'api' access scope: to be able to make api calls")