diff options
author | Mikhail Mazurskiy <mmazurskiy@gitlab.com> | 2021-09-09 21:05:25 +1000 |
---|---|---|
committer | Mikhail Mazurskiy <mmazurskiy@gitlab.com> | 2021-09-09 21:05:25 +1000 |
commit | 44737afce375d68a3c122991f6d94e3a84233dbb (patch) | |
tree | 7d5b299ce6bcddcb0bdf33fa24a1c42c5e65e882 /internal | |
parent | 5edb579c23a06a2795c199478c88782b25f34d0d (diff) | |
download | gitlab-shell-ash2k/use-moved-gitlab-client.tar.gz |
Use moved GitLab client from Gitalyash2k/use-moved-gitlab-client
See https://gitlab.com/gitlab-org/gitaly/-/merge_requests/3850
Diffstat (limited to 'internal')
18 files changed, 38 insertions, 53 deletions
diff --git a/internal/command/shared/customaction/customaction.go b/internal/command/shared/customaction/customaction.go index 34086fb..c110871 100644 --- a/internal/command/shared/customaction/customaction.go +++ b/internal/command/shared/customaction/customaction.go @@ -4,12 +4,10 @@ import ( "bytes" "context" "errors" - - "gitlab.com/gitlab-org/gitlab-shell/client" - "io" "net/http" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/internal/command/readwriter" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet" @@ -97,7 +95,7 @@ func (c *Command) processApiEndpoints(ctx context.Context, response *accessverif return nil } -func (c *Command) performRequest(ctx context.Context, client *client.GitlabNetClient, endpoint string, request *Request) (*Response, error) { +func (c *Command) performRequest(ctx context.Context, client *gitnet.GitlabNetClient, endpoint string, request *Request) (*Response, error) { response, err := client.DoRequest(ctx, http.MethodPost, endpoint, request) if err != nil { return nil, err diff --git a/internal/config/config.go b/internal/config/config.go index c67f60a..e5edb52 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -12,7 +12,7 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" yaml "gopkg.in/yaml.v2" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/internal/metrics" ) @@ -56,7 +56,7 @@ type Config struct { HttpSettings HttpSettingsConfig `yaml:"http_settings"` Server ServerConfig `yaml:"sshd"` - httpClient *client.HttpClient + httpClient *gitnet.HttpClient httpClientErr error httpClientOnce sync.Once } @@ -95,9 +95,9 @@ func (c *Config) ApplyGlobalState() { } } -func (c *Config) HttpClient() (*client.HttpClient, error) { +func (c *Config) HttpClient() (*gitnet.HttpClient, error) { c.httpClientOnce.Do(func() { - client, err := client.NewHTTPClientWithOpts( + client, err := gitnet.NewHTTPClientWithOpts( c.GitlabUrl, c.GitlabRelativeURLRoot, c.HttpSettings.CaFile, diff --git a/internal/gitlabnet/accessverifier/client.go b/internal/gitlabnet/accessverifier/client.go index bce32cf..b595b8a 100644 --- a/internal/gitlabnet/accessverifier/client.go +++ b/internal/gitlabnet/accessverifier/client.go @@ -5,8 +5,8 @@ import ( "fmt" "net/http" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" pb "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" - "gitlab.com/gitlab-org/gitlab-shell/client" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet" @@ -18,7 +18,7 @@ const ( ) type Client struct { - client *client.GitlabNetClient + client *gitnet.GitlabNetClient } type Request struct { diff --git a/internal/gitlabnet/accessverifier/client_test.go b/internal/gitlabnet/accessverifier/client_test.go index f617c38..51dc375 100644 --- a/internal/gitlabnet/accessverifier/client_test.go +++ b/internal/gitlabnet/accessverifier/client_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/stretchr/testify/require" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" pb "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" - "gitlab.com/gitlab-org/gitlab-shell/client" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/internal/config" @@ -209,7 +209,7 @@ func setup(t *testing.T, allowedPayload string) *Client { require.NoError(t, err) case "2": w.WriteHeader(http.StatusForbidden) - errBody := &client.ErrorResponse{ + errBody := &gitnet.ErrorResponse{ Message: "Not allowed!", } require.NoError(t, json.NewEncoder(w).Encode(errBody)) diff --git a/internal/gitlabnet/authorizedkeys/client.go b/internal/gitlabnet/authorizedkeys/client.go index 0a00034..79513da 100644 --- a/internal/gitlabnet/authorizedkeys/client.go +++ b/internal/gitlabnet/authorizedkeys/client.go @@ -5,7 +5,7 @@ import ( "fmt" "net/url" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet" ) @@ -16,7 +16,7 @@ const ( type Client struct { config *config.Config - client *client.GitlabNetClient + client *gitnet.GitlabNetClient } type Response struct { diff --git a/internal/gitlabnet/authorizedkeys/client_test.go b/internal/gitlabnet/authorizedkeys/client_test.go index 073e5c1..6eb6744 100644 --- a/internal/gitlabnet/authorizedkeys/client_test.go +++ b/internal/gitlabnet/authorizedkeys/client_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/config" ) @@ -29,7 +29,7 @@ func init() { json.NewEncoder(w).Encode(body) } else if r.URL.Query().Get("key") == "broken-message" { w.WriteHeader(http.StatusForbidden) - body := &client.ErrorResponse{ + body := &gitnet.ErrorResponse{ Message: "Not allowed!", } json.NewEncoder(w).Encode(body) diff --git a/internal/gitlabnet/client.go b/internal/gitlabnet/client.go index 39c3320..d63cfdf 100644 --- a/internal/gitlabnet/client.go +++ b/internal/gitlabnet/client.go @@ -5,8 +5,7 @@ import ( "fmt" "net/http" - "gitlab.com/gitlab-org/gitlab-shell/client" - + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/internal/config" ) @@ -14,7 +13,7 @@ var ( ParsingError = fmt.Errorf("Parsing failed") ) -func GetClient(config *config.Config) (*client.GitlabNetClient, error) { +func GetClient(config *config.Config) (*gitnet.GitlabNetClient, error) { httpClient, err := config.HttpClient() if err != nil { return nil, err @@ -24,7 +23,7 @@ func GetClient(config *config.Config) (*client.GitlabNetClient, error) { return nil, fmt.Errorf("Unsupported protocol") } - return client.NewGitlabNetClient(config.HttpSettings.User, config.HttpSettings.Password, config.Secret, httpClient) + return gitnet.NewGitlabNetClient(config.HttpSettings.User, config.HttpSettings.Password, config.Secret, httpClient) } func ParseJSON(hr *http.Response, response interface{}) error { diff --git a/internal/gitlabnet/discover/client.go b/internal/gitlabnet/discover/client.go index cc7f516..f930cec 100644 --- a/internal/gitlabnet/discover/client.go +++ b/internal/gitlabnet/discover/client.go @@ -6,7 +6,7 @@ import ( "net/http" "net/url" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet" @@ -14,7 +14,7 @@ import ( type Client struct { config *config.Config - client *client.GitlabNetClient + client *gitnet.GitlabNetClient } type Response struct { diff --git a/internal/gitlabnet/discover/client_test.go b/internal/gitlabnet/discover/client_test.go index ef35053..6dc768b 100644 --- a/internal/gitlabnet/discover/client_test.go +++ b/internal/gitlabnet/discover/client_test.go @@ -8,9 +8,8 @@ import ( "net/url" "testing" - "gitlab.com/gitlab-org/gitlab-shell/client" - "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/config" ) @@ -40,7 +39,7 @@ func init() { json.NewEncoder(w).Encode(body) } else if r.URL.Query().Get("username") == "broken_message" { w.WriteHeader(http.StatusForbidden) - body := &client.ErrorResponse{ + body := &gitlabnet.ErrorResponse{ Message: "Not allowed!", } json.NewEncoder(w).Encode(body) diff --git a/internal/gitlabnet/healthcheck/client.go b/internal/gitlabnet/healthcheck/client.go index f148504..02bd77f 100644 --- a/internal/gitlabnet/healthcheck/client.go +++ b/internal/gitlabnet/healthcheck/client.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet" ) @@ -16,7 +16,7 @@ const ( type Client struct { config *config.Config - client *client.GitlabNetClient + client *gitnet.GitlabNetClient } type Response struct { diff --git a/internal/gitlabnet/lfsauthenticate/client.go b/internal/gitlabnet/lfsauthenticate/client.go index 834cbe1..684aee0 100644 --- a/internal/gitlabnet/lfsauthenticate/client.go +++ b/internal/gitlabnet/lfsauthenticate/client.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet" @@ -14,7 +14,7 @@ import ( type Client struct { config *config.Config - client *client.GitlabNetClient + client *gitnet.GitlabNetClient args *commandargs.Shell } diff --git a/internal/gitlabnet/personalaccesstoken/client.go b/internal/gitlabnet/personalaccesstoken/client.go index abbd395..6f35198 100644 --- a/internal/gitlabnet/personalaccesstoken/client.go +++ b/internal/gitlabnet/personalaccesstoken/client.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet" @@ -15,7 +15,7 @@ import ( type Client struct { config *config.Config - client *client.GitlabNetClient + client *gitnet.GitlabNetClient } type Response struct { diff --git a/internal/gitlabnet/personalaccesstoken/client_test.go b/internal/gitlabnet/personalaccesstoken/client_test.go index d36cd44..978866d 100644 --- a/internal/gitlabnet/personalaccesstoken/client_test.go +++ b/internal/gitlabnet/personalaccesstoken/client_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/internal/config" @@ -49,7 +49,7 @@ func initialize(t *testing.T) { json.NewEncoder(w).Encode(body) case "2": w.WriteHeader(http.StatusForbidden) - body := &client.ErrorResponse{ + body := &gitnet.ErrorResponse{ Message: "Not allowed!", } json.NewEncoder(w).Encode(body) diff --git a/internal/gitlabnet/twofactorrecover/client.go b/internal/gitlabnet/twofactorrecover/client.go index 456f892..f562ba6 100644 --- a/internal/gitlabnet/twofactorrecover/client.go +++ b/internal/gitlabnet/twofactorrecover/client.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet" @@ -15,7 +15,7 @@ import ( type Client struct { config *config.Config - client *client.GitlabNetClient + client *gitnet.GitlabNetClient } type Response struct { diff --git a/internal/gitlabnet/twofactorrecover/client_test.go b/internal/gitlabnet/twofactorrecover/client_test.go index 921c114..412c88e 100644 --- a/internal/gitlabnet/twofactorrecover/client_test.go +++ b/internal/gitlabnet/twofactorrecover/client_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/internal/config" @@ -47,7 +47,7 @@ func initialize(t *testing.T) { json.NewEncoder(w).Encode(body) case "2": w.WriteHeader(http.StatusForbidden) - body := &client.ErrorResponse{ + body := &gitnet.ErrorResponse{ Message: "Not allowed!", } json.NewEncoder(w).Encode(body) diff --git a/internal/gitlabnet/twofactorverify/client.go b/internal/gitlabnet/twofactorverify/client.go index aab302b..48258b2 100644 --- a/internal/gitlabnet/twofactorverify/client.go +++ b/internal/gitlabnet/twofactorverify/client.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet" @@ -15,7 +15,7 @@ import ( type Client struct { config *config.Config - client *client.GitlabNetClient + client *gitnet.GitlabNetClient } type Response struct { diff --git a/internal/gitlabnet/twofactorverify/client_test.go b/internal/gitlabnet/twofactorverify/client_test.go index e4f837b..2c425b8 100644 --- a/internal/gitlabnet/twofactorverify/client_test.go +++ b/internal/gitlabnet/twofactorverify/client_test.go @@ -7,13 +7,12 @@ import ( "net/http" "testing" - "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/discover" - "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitlab-shell/client" + gitnet "gitlab.com/gitlab-org/gitaly/v14/gitlabnet" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" "gitlab.com/gitlab-org/gitlab-shell/internal/config" + "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/discover" ) func initialize(t *testing.T) []testserver.TestRequestHandler { @@ -43,7 +42,7 @@ func initialize(t *testing.T) []testserver.TestRequestHandler { require.NoError(t, json.NewEncoder(w).Encode(body)) case "2": w.WriteHeader(http.StatusForbidden) - body := &client.ErrorResponse{ + body := &gitnet.ErrorResponse{ Message: "Not allowed!", } require.NoError(t, json.NewEncoder(w).Encode(body)) diff --git a/internal/testhelper/testdata/testroot/certs/invalid/server.crt b/internal/testhelper/testdata/testroot/certs/invalid/server.crt deleted file mode 100644 index f8a42c1..0000000 --- a/internal/testhelper/testdata/testroot/certs/invalid/server.crt +++ /dev/null @@ -1,10 +0,0 @@ ------BEGIN CERTIFICATE----- -MinvalidcertAOvHjs6cs1R9MAoGCCqGSM49BAMCMBQxEjAQBgNVBAMMCWxvY2Fs -ainvalidcertOTA0MjQxNjM4NTBaFw0yOTA0MjExNjM4NTBaMBQxEjAQBgNVBAMM -CinvalidcertdDB2MBAGByqGSM49AgEGBSuBBAAiA2IABJ5m7oW9OuL7aTAC04sL -3invalidcertdB2L0GsVCImav4PEpx6UAjkoiNGW9j0zPdNgxTYDjiCaGmr1aY2X -kinvalidcert7MNq7H8v7Ce/vrKkcDMOX8Gd/ddT3dEVqzAKBggqhkjOPQQDAgNp -AinvalidcertswcyjiB+A+ZjMSfaOsA2hAP0I3fkTcry386DePViMfnaIjm7rcuu -Jinvalidcert5V5CHypOxio1tOtGjaDkSH2FCdoatMyIe02+F6TIo44i4J/zjN52 -Jinvalidcert ------END CERTIFICATE----- |