Skip to content

Commit 93da333

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

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
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/server.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ M.build = function(override)
9797
end
9898

9999
local res = vim
100-
.system({ "go", "build", "-o", bin_name }, { cwd = state.settings.root_path .. u.path_separator .. "cmd" })
101-
:wait()
100+
.system({ "go", "build", "-o", bin_name }, { cwd = state.settings.root_path .. u.path_separator .. "cmd" })
101+
:wait()
102102

103103
if res.code ~= 0 then
104104
u.notify(string.format("Failed to install with status code %d:\n%s", res.code, res.stderr), vim.log.levels.ERROR)

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)