As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit b0834a9a authored by Vasilii Iakliushin's avatar Vasilii Iakliushin
Browse files

Remove more code

parent 06e0f89d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -30,12 +30,11 @@ type ErrorResponse struct {
// GitlabNetClient is a client for interacting with GitLab API
type GitlabNetClient struct {
HttpClient *HTTPClient
user string
password string
secret string
userAgent string
httpClient *HTTPClient
user string
password string
secret string
userAgent string
}
// APIError represents an API error
Loading
Loading
@@ -62,7 +61,7 @@ func NewGitlabNetClient(
}
return &GitlabNetClient{
HttpClient: httpClient,
httpClient: httpClient,
user: user,
password: password,
secret: secret,
Loading
Loading
@@ -129,17 +128,17 @@ func parseError(resp *http.Response, respErr error) error {
// Get makes a GET request
func (c *GitlabNetClient) Get(ctx context.Context, path string) (*http.Response, error) {
return c.DoRequest(ctx, http.MethodGet, c.HttpClient.Host, normalizePath(path), nil)
return c.DoRequest(ctx, http.MethodGet, normalizePath(path), nil)
}
// Post makes a POST request
func (c *GitlabNetClient) Post(ctx context.Context, path string, data interface{}) (*http.Response, error) {
return c.DoRequest(ctx, http.MethodPost, c.HttpClient.Host, normalizePath(path), data)
return c.DoRequest(ctx, http.MethodPost, normalizePath(path), data)
}
// Do executes a request
func (c *GitlabNetClient) Do(request *http.Request) (*http.Response, error) {
response, respErr := c.HttpClient.RetryableHTTP.HTTPClient.Do(request)
response, respErr := c.httpClient.RetryableHTTP.HTTPClient.Do(request)
if err := parseError(response, respErr); err != nil {
return nil, err
}
Loading
Loading
@@ -148,8 +147,8 @@ func (c *GitlabNetClient) Do(request *http.Request) (*http.Response, error) {
}
// DoRequest executes a request with the given method, path, and data
func (c *GitlabNetClient) DoRequest(ctx context.Context, method, host, path string, data interface{}) (*http.Response, error) {
request, err := newRequest(ctx, method, host, path, data)
func (c *GitlabNetClient) DoRequest(ctx context.Context, method, path string, data interface{}) (*http.Response, error) {
request, err := newRequest(ctx, method, c.httpClient.Host, path, data)
if err != nil {
return nil, err
}
Loading
Loading
@@ -174,7 +173,7 @@ func (c *GitlabNetClient) DoRequest(ctx context.Context, method, host, path stri
request.Header.Add("Content-Type", "application/json")
request.Header.Add("User-Agent", c.userAgent)
response, respErr := c.HttpClient.RetryableHTTP.Do(request)
response, respErr := c.httpClient.RetryableHTTP.Do(request)
if err := parseError(response, respErr); err != nil {
return nil, err
}
Loading
Loading
Loading
Loading
@@ -107,7 +107,7 @@ func (c *Command) processAPIEndpoints(ctx context.Context, response *accessverif
}
func (c *Command) performRequest(ctx context.Context, client *client.GitlabNetClient, endpoint string, request *Request) (*Response, error) {
response, err := client.DoRequest(ctx, http.MethodPost, client.HttpClient.Host, endpoint, request)
response, err := client.DoRequest(ctx, http.MethodPost, endpoint, request)
if err != nil {
return nil, err
}
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ import (
func (c *Command) performWorkhorseCall(ctx context.Context, response *accessverifier.Response) error {
client := &git.Client{
Url: response.GitRpcUrl,
URL: response.GitRpcUrl,
Headers: map[string]string{
"Gitlab-Shell-Api-Request": response.GitRpcAuthHeader,
"Git-Protocol": c.Args.Env.GitProtocolVersion,
Loading
Loading
Loading
Loading
@@ -21,8 +21,6 @@ const (
// Client is a client for accessing resources
type Client struct {
client *client.GitlabNetClient
config *config.Config
host string
}
// Request represents a request for accessing resources
Loading
Loading
@@ -98,7 +96,7 @@ func NewClient(config *config.Config) (*Client, error) {
return nil, fmt.Errorf("error creating http client: %v", err)
}
return &Client{client: client, config: config, host: client.HttpClient.Host}, nil
return &Client{client: client}, nil
}
// Verify verifies access to a GitLab resource
Loading
Loading
@@ -122,7 +120,7 @@ func (c *Client) Verify(ctx context.Context, args *commandargs.Shell, action com
request.CheckIP = gitlabnet.ParseIP(args.Env.RemoteAddr)
response, err := c.client.DoRequest(ctx, http.MethodPost, c.host, "/api/v4/internal/allowed", request)
response, err := c.client.Post(ctx, "/allowed", request)
if err != nil {
return nil, err
}
Loading
Loading
Loading
Loading
@@ -58,7 +58,7 @@ func (c *Client) UploadPack(ctx context.Context, body io.Reader) (*http.Response
// SshUploadPack sends a SSH over HTTPS request to the server
func (c *Client) SshUploadPack(ctx context.Context, body io.Reader) (*http.Response, error) {
request, err := http.NewRequestWithContext(ctx, http.MethodPost, c.Url, body)
request, err := http.NewRequestWithContext(ctx, http.MethodPost, c.URL, body)
if err != nil {
return nil, err
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment