diff options
author | Patrick Bajao <ebajao@gitlab.com> | 2019-07-29 15:59:23 +0800 |
---|---|---|
committer | Patrick Bajao <ebajao@gitlab.com> | 2019-07-31 12:03:43 +0800 |
commit | 592823d5e25006331b361b36cc61df7802fc1938 (patch) | |
tree | e5dfda205795e9526eb94866de65073cd6a83915 /go/internal/gitlabnet | |
parent | 3b0176df497263323da2fae793a79b568502e6db (diff) | |
download | gitlab-shell-592823d5e25006331b361b36cc61df7802fc1938.tar.gz |
Rename CommandArgs to Shell
Other functions are still expecting for `CommandArgs` instead
of `Shell`. They should be expecting `commandargs.Shell` now
since it has been renamed.
Diffstat (limited to 'go/internal/gitlabnet')
-rw-r--r-- | go/internal/gitlabnet/accessverifier/client.go | 4 | ||||
-rw-r--r-- | go/internal/gitlabnet/accessverifier/client_test.go | 10 | ||||
-rw-r--r-- | go/internal/gitlabnet/discover/client.go | 2 | ||||
-rw-r--r-- | go/internal/gitlabnet/lfsauthenticate/client.go | 4 | ||||
-rw-r--r-- | go/internal/gitlabnet/lfsauthenticate/client_test.go | 10 | ||||
-rw-r--r-- | go/internal/gitlabnet/twofactorrecover/client.go | 4 | ||||
-rw-r--r-- | go/internal/gitlabnet/twofactorrecover/client_test.go | 8 |
7 files changed, 21 insertions, 21 deletions
diff --git a/go/internal/gitlabnet/accessverifier/client.go b/go/internal/gitlabnet/accessverifier/client.go index d87c4ad..92a7434 100644 --- a/go/internal/gitlabnet/accessverifier/client.go +++ b/go/internal/gitlabnet/accessverifier/client.go @@ -71,7 +71,7 @@ func NewClient(config *config.Config) (*Client, error) { return &Client{client: client}, nil } -func (c *Client) Verify(args *commandargs.CommandArgs, action commandargs.CommandType, repo string) (*Response, error) { +func (c *Client) Verify(args *commandargs.Shell, action commandargs.CommandType, repo string) (*Response, error) { request := &Request{Action: action, Repo: repo, Protocol: protocol, Changes: anyChanges} if args.GitlabUsername != "" { @@ -89,7 +89,7 @@ func (c *Client) Verify(args *commandargs.CommandArgs, action commandargs.Comman return parse(response, args) } -func parse(hr *http.Response, args *commandargs.CommandArgs) (*Response, error) { +func parse(hr *http.Response, args *commandargs.Shell) (*Response, error) { response := &Response{} if err := gitlabnet.ParseJSON(hr, response); err != nil { return nil, err diff --git a/go/internal/gitlabnet/accessverifier/client_test.go b/go/internal/gitlabnet/accessverifier/client_test.go index 31175ae..f534185 100644 --- a/go/internal/gitlabnet/accessverifier/client_test.go +++ b/go/internal/gitlabnet/accessverifier/client_test.go @@ -57,16 +57,16 @@ func TestSuccessfulResponses(t *testing.T) { testCases := []struct { desc string - args *commandargs.CommandArgs + args *commandargs.Shell who string }{ { desc: "Provide key id within the request", - args: &commandargs.CommandArgs{GitlabKeyId: "1"}, + args: &commandargs.Shell{GitlabKeyId: "1"}, who: "key-1", }, { desc: "Provide username within the request", - args: &commandargs.CommandArgs{GitlabUsername: "first"}, + args: &commandargs.Shell{GitlabUsername: "first"}, who: "user-1", }, } @@ -86,7 +86,7 @@ func TestGetCustomAction(t *testing.T) { client, cleanup := setup(t) defer cleanup() - args := &commandargs.CommandArgs{GitlabUsername: "custom"} + args := &commandargs.Shell{GitlabUsername: "custom"} result, err := client.Verify(args, action, repo) require.NoError(t, err) @@ -134,7 +134,7 @@ func TestErrorResponses(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - args := &commandargs.CommandArgs{GitlabKeyId: tc.fakeId} + args := &commandargs.Shell{GitlabKeyId: tc.fakeId} resp, err := client.Verify(args, action, repo) require.EqualError(t, err, tc.expectedError) diff --git a/go/internal/gitlabnet/discover/client.go b/go/internal/gitlabnet/discover/client.go index 675670d..46ab2de 100644 --- a/go/internal/gitlabnet/discover/client.go +++ b/go/internal/gitlabnet/discover/client.go @@ -30,7 +30,7 @@ func NewClient(config *config.Config) (*Client, error) { return &Client{config: config, client: client}, nil } -func (c *Client) GetByCommandArgs(args *commandargs.CommandArgs) (*Response, error) { +func (c *Client) GetByCommandArgs(args *commandargs.Shell) (*Response, error) { params := url.Values{} if args.GitlabUsername != "" { params.Add("username", args.GitlabUsername) diff --git a/go/internal/gitlabnet/lfsauthenticate/client.go b/go/internal/gitlabnet/lfsauthenticate/client.go index 2a7cb03..51cb7a4 100644 --- a/go/internal/gitlabnet/lfsauthenticate/client.go +++ b/go/internal/gitlabnet/lfsauthenticate/client.go @@ -13,7 +13,7 @@ import ( type Client struct { config *config.Config client *gitlabnet.GitlabClient - args *commandargs.CommandArgs + args *commandargs.Shell } type Request struct { @@ -30,7 +30,7 @@ type Response struct { ExpiresIn int `json:"expires_in"` } -func NewClient(config *config.Config, args *commandargs.CommandArgs) (*Client, error) { +func NewClient(config *config.Config, args *commandargs.Shell) (*Client, error) { client, err := gitlabnet.GetClient(config) if err != nil { return nil, fmt.Errorf("Error creating http client: %v", err) diff --git a/go/internal/gitlabnet/lfsauthenticate/client_test.go b/go/internal/gitlabnet/lfsauthenticate/client_test.go index 7fd7aca..07484a7 100644 --- a/go/internal/gitlabnet/lfsauthenticate/client_test.go +++ b/go/internal/gitlabnet/lfsauthenticate/client_test.go @@ -59,22 +59,22 @@ func TestFailedRequests(t *testing.T) { testCases := []struct { desc string - args *commandargs.CommandArgs + args *commandargs.Shell expectedOutput string }{ { desc: "With bad response", - args: &commandargs.CommandArgs{GitlabKeyId: "-1", CommandType: commandargs.UploadPack}, + args: &commandargs.Shell{GitlabKeyId: "-1", CommandType: commandargs.UploadPack}, expectedOutput: "Parsing failed", }, { desc: "With API returns an error", - args: &commandargs.CommandArgs{GitlabKeyId: "forbidden", CommandType: commandargs.UploadPack}, + args: &commandargs.Shell{GitlabKeyId: "forbidden", CommandType: commandargs.UploadPack}, expectedOutput: "Internal API error (403)", }, { desc: "With API fails", - args: &commandargs.CommandArgs{GitlabKeyId: "broken", CommandType: commandargs.UploadPack}, + args: &commandargs.Shell{GitlabKeyId: "broken", CommandType: commandargs.UploadPack}, expectedOutput: "Internal API error (500)", }, } @@ -99,7 +99,7 @@ func TestSuccessfulRequests(t *testing.T) { url, cleanup := testserver.StartHttpServer(t, requests) defer cleanup() - args := &commandargs.CommandArgs{GitlabKeyId: keyId, CommandType: commandargs.LfsAuthenticate} + args := &commandargs.Shell{GitlabKeyId: keyId, CommandType: commandargs.LfsAuthenticate} client, err := NewClient(&config.Config{GitlabUrl: url}, args) require.NoError(t, err) diff --git a/go/internal/gitlabnet/twofactorrecover/client.go b/go/internal/gitlabnet/twofactorrecover/client.go index f90a85c..37067db 100644 --- a/go/internal/gitlabnet/twofactorrecover/client.go +++ b/go/internal/gitlabnet/twofactorrecover/client.go @@ -36,7 +36,7 @@ func NewClient(config *config.Config) (*Client, error) { return &Client{config: config, client: client}, nil } -func (c *Client) GetRecoveryCodes(args *commandargs.CommandArgs) ([]string, error) { +func (c *Client) GetRecoveryCodes(args *commandargs.Shell) ([]string, error) { requestBody, err := c.getRequestBody(args) if err != nil { @@ -65,7 +65,7 @@ func parse(hr *http.Response) ([]string, error) { return response.RecoveryCodes, nil } -func (c *Client) getRequestBody(args *commandargs.CommandArgs) (*RequestBody, error) { +func (c *Client) getRequestBody(args *commandargs.Shell) (*RequestBody, error) { client, err := discover.NewClient(c.config) if err != nil { diff --git a/go/internal/gitlabnet/twofactorrecover/client_test.go b/go/internal/gitlabnet/twofactorrecover/client_test.go index 4b15ac5..a560fb1 100644 --- a/go/internal/gitlabnet/twofactorrecover/client_test.go +++ b/go/internal/gitlabnet/twofactorrecover/client_test.go @@ -85,7 +85,7 @@ func TestGetRecoveryCodesByKeyId(t *testing.T) { client, cleanup := setup(t) defer cleanup() - args := &commandargs.CommandArgs{GitlabKeyId: "0"} + args := &commandargs.Shell{GitlabKeyId: "0"} result, err := client.GetRecoveryCodes(args) assert.NoError(t, err) assert.Equal(t, []string{"recovery 1", "codes 1"}, result) @@ -95,7 +95,7 @@ func TestGetRecoveryCodesByUsername(t *testing.T) { client, cleanup := setup(t) defer cleanup() - args := &commandargs.CommandArgs{GitlabUsername: "jane-doe"} + args := &commandargs.Shell{GitlabUsername: "jane-doe"} result, err := client.GetRecoveryCodes(args) assert.NoError(t, err) assert.Equal(t, []string{"recovery 2", "codes 2"}, result) @@ -105,7 +105,7 @@ func TestMissingUser(t *testing.T) { client, cleanup := setup(t) defer cleanup() - args := &commandargs.CommandArgs{GitlabKeyId: "1"} + args := &commandargs.Shell{GitlabKeyId: "1"} _, err := client.GetRecoveryCodes(args) assert.Equal(t, "missing user", err.Error()) } @@ -138,7 +138,7 @@ func TestErrorResponses(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - args := &commandargs.CommandArgs{GitlabKeyId: tc.fakeId} + args := &commandargs.Shell{GitlabKeyId: tc.fakeId} resp, err := client.GetRecoveryCodes(args) assert.EqualError(t, err, tc.expectedError) |