summaryrefslogtreecommitdiff
path: root/go/internal/gitlabnet/client.go
diff options
context:
space:
mode:
authorMałgorzata Ksionek <mksionek@gitlab.com>2019-09-19 12:36:53 +0200
committerMałgorzata Ksionek <mksionek@gitlab.com>2019-09-26 12:26:53 +0200
commit216bfafb4c0001a476e5ca630cd8c3baf7718d8d (patch)
treee84d1c3a906cea89f75e8564b422632fa0d75d93 /go/internal/gitlabnet/client.go
parent7f0f6e7621cbc60504f0c1f1bf1541d5b95a4ff8 (diff)
downloadgitlab-shell-216bfafb4c0001a476e5ca630cd8c3baf7718d8d.tar.gz
Add code review remarks
Diffstat (limited to 'go/internal/gitlabnet/client.go')
-rw-r--r--go/internal/gitlabnet/client.go12
1 files changed, 1 insertions, 11 deletions
diff --git a/go/internal/gitlabnet/client.go b/go/internal/gitlabnet/client.go
index 26c24d4..b668fbd 100644
--- a/go/internal/gitlabnet/client.go
+++ b/go/internal/gitlabnet/client.go
@@ -7,7 +7,6 @@ import (
"fmt"
"io"
"net/http"
- "os"
"strings"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
@@ -110,8 +109,7 @@ func (c *GitlabClient) DoRequest(method, path string, data interface{}) (*http.R
request.Header.Set(secretHeaderName, encodedSecret)
request.Header.Add("Content-Type", "application/json")
- ip := ipAddr()
- request.Header.Add("X_FORWARDED_FOR", ip)
+ request.Header.Add("X_FORWARDED_FOR", c.config.IpAddr())
request.Close = true
@@ -127,14 +125,6 @@ func (c *GitlabClient) DoRequest(method, path string, data interface{}) (*http.R
return response, nil
}
-func ipAddr() string {
- address := os.Getenv("SSH_CONNECTION")
- if address != "" {
- return strings.Fields(address)[0]
- }
- return address
-}
-
func ParseJSON(hr *http.Response, response interface{}) error {
if err := json.NewDecoder(hr.Body).Decode(response); err != nil {
return ParsingError