Skip to content

Commit a9abe3a

Browse files
committed
Enable using a proxy to connect to GitLab
1 parent 9feab41 commit a9abe3a

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

cmd/app/client.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"net/http"
9+
"net/url"
910

1011
"github.com/harrisoncramer/gitlab.nvim/cmd/app/git"
1112
"github.com/hashicorp/go-retryablehttp"
@@ -66,6 +67,14 @@ func NewClient() (*Client, error) {
6667
},
6768
}
6869

70+
if proxy := pluginOptions.ConnectionSettings.Proxy; proxy != "" {
71+
u, err := url.Parse(proxy)
72+
if err != nil {
73+
return nil, fmt.Errorf("parse proxy url: %w", err)
74+
}
75+
tr.Proxy = http.ProxyURL(u)
76+
}
77+
6978
retryClient := retryablehttp.NewClient()
7079
retryClient.HTTPClient.Transport = tr
7180
gitlabOptions = append(gitlabOptions, gitlab.WithHTTPClient(retryClient.HTTPClient))

cmd/app/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type PluginOptions struct {
1313
} `json:"debug"`
1414
ChosenMrIID int `json:"chosen_mr_iid"`
1515
ConnectionSettings struct {
16+
Proxy string `json:"proxy"`
1617
Insecure bool `json:"insecure"`
1718
Remote string `json:"remote"`
1819
} `json:"connection_settings"`

doc/gitlab.nvim.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ you call this function with no values the defaults will be used:
161161
},
162162
},
163163
connection_settings = {
164+
proxy = "", -- Configure a proxy URL to use when connecting to GitLab. Supports URL schemes: http, https, socks5
164165
insecure = false, -- Like curl's --insecure option, ignore bad x509 certificates on connection
165166
remote = "origin", -- The default remote that your MRs target
166167
},

lua/gitlab/state.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ M.settings = {
6262
},
6363
},
6464
connection_settings = {
65+
proxy = "",
6566
insecure = false,
6667
remote = "origin",
6768
},

0 commit comments

Comments
 (0)