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 06e0f89d authored by Vasilii Iakliushin's avatar Vasilii Iakliushin
Browse files

Remove cells code

parent 59e8b7d3
No related branches found
No related tags found
No related merge requests found
package cells
import (
"google.golang.org/grpc"
)
type Client struct {
conn *grpc.ClientConn
}
func NewClient(url string) (*Client, error) {
conn, err := grpc.Dial(url, grpc.WithInsecure())
if err != nil {
return nil, err
}
return &Client{conn: conn}, nil
}
Loading
Loading
@@ -3,25 +3,22 @@ package uploadpack
import (
"context"
"io"
"net/http"
"gitlab.com/gitlab-org/gitlab-shell/v14/client"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/command/shared/accessverifier"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/gitlabnet/git"
)
var httpClient = &http.Client{
Transport: client.NewTransport(client.DefaultTransport()),
}
func (c *Command) performWorkhorseCall(ctx context.Context, response *accessverifier.Response) error {
req, err := http.NewRequestWithContext(ctx, http.MethodPost, response.GitRpcUrl, io.NopCloser(c.ReadWriter.In))
if err != nil {
return err
client := &git.Client{
Url: response.GitRpcUrl,
Headers: map[string]string{
"Gitlab-Shell-Api-Request": response.GitRpcAuthHeader,
"Git-Protocol": c.Args.Env.GitProtocolVersion,
},
}
req.Header.Set("Authorization", response.GitRpcAuthHeader)
req.Header.Set("Git-Protocol", c.Args.Env.GitProtocolVersion)
resp, err := httpClient.Do(req)
resp, err := client.SshUploadPack(ctx, io.NopCloser(c.ReadWriter.In))
if err != nil {
return err
}
Loading
Loading
Loading
Loading
@@ -12,7 +12,6 @@ import (
"gopkg.in/yaml.v3"
"gitlab.com/gitlab-org/gitlab-shell/v14/client"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/cells"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/gitaly"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/metrics"
)
Loading
Loading
@@ -66,12 +65,6 @@ type LFSConfig struct {
PureSSHProtocol bool // `yaml:"pure_ssh_protocol"`
}
type CellsConfig struct {
Url string `yaml:"url"`
Client *cells.Client
}
type Config struct {
User string `yaml:"user,omitempty"`
RootDir string
Loading
Loading
@@ -88,7 +81,6 @@ type Config struct {
HttpSettings HttpSettingsConfig `yaml:"http_settings"`
Server ServerConfig `yaml:"sshd"`
LFSConfig LFSConfig `yaml:"lfs"`
Cells CellsConfig `yaml:"cells"`
httpClient *client.HTTPClient
httpClientErr error
Loading
Loading
@@ -219,14 +211,6 @@ func newFromFile(path string) (*Config, error) {
cfg.LogFile = filepath.Join(cfg.RootDir, cfg.LogFile)
}
if cfg.Cells.Url != "" {
client, err := cells.NewClient(cfg.Cells.Url)
if err != nil {
return nil, err
}
cfg.Cells.Client = client
}
return cfg, nil
}
Loading
Loading
Loading
Loading
@@ -122,8 +122,7 @@ func (c *Client) Verify(ctx context.Context, args *commandargs.Shell, action com
request.CheckIP = gitlabnet.ParseIP(args.Env.RemoteAddr)
host := c.getCellsAddress(ctx, repo)
response, err := c.client.DoRequest(ctx, http.MethodPost, host, "/api/v4/internal/allowed", request)
response, err := c.client.DoRequest(ctx, http.MethodPost, c.host, "/api/v4/internal/allowed", request)
if err != nil {
return nil, err
}
Loading
Loading
@@ -153,19 +152,3 @@ func parse(hr *http.Response, args *commandargs.Shell) (*Response, error) {
func (r *Response) IsCustomAction() bool {
return r.StatusCode == http.StatusMultipleChoices
}
func (c *Client) getCellsAddress(ctx context.Context, repo string) string {
cellsClient := c.config.Cells.Client
if cellsClient == nil {
return c.host
}
return c.host
// cell, err := cellsClient.Classify(ctx, repo)
// if err != nil {
// return c.host
// }
// return cell.Address
}
Loading
Loading
@@ -56,6 +56,16 @@ func (c *Client) UploadPack(ctx context.Context, body io.Reader) (*http.Response
return c.do(request)
}
// 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)
if err != nil {
return nil, err
}
return c.do(request)
}
func (c *Client) do(request *http.Request) (*http.Response, error) {
for k, v := range c.Headers {
request.Header.Add(k, v)
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