diff --git a/backend/plugins/gitextractor/parser/clone.go b/backend/plugins/gitextractor/parser/clone.go index f9e05df8eb3..b9db6820c47 100644 --- a/backend/plugins/gitextractor/parser/clone.go +++ b/backend/plugins/gitextractor/parser/clone.go @@ -59,7 +59,7 @@ func (l *GitRepoCreator) CloneOverHTTP(repoId, url, user, password, proxy string return withTempDirectory(func(dir string) (*GitRepo, error) { cloneOptions := &git.CloneOptions{Bare: true} if proxy != "" { - cloneOptions.FetchOptions.ProxyOptions.Type = git.ProxyTypeAuto + cloneOptions.FetchOptions.ProxyOptions.Type = git.ProxyTypeSpecified cloneOptions.FetchOptions.ProxyOptions.Url = proxy } if user != "" { diff --git a/backend/plugins/github_graphql/impl/impl.go b/backend/plugins/github_graphql/impl/impl.go index 331e285a0b6..fc035caa9dc 100644 --- a/backend/plugins/github_graphql/impl/impl.go +++ b/backend/plugins/github_graphql/impl/impl.go @@ -20,6 +20,7 @@ package impl import ( "context" "fmt" + "net/http" "net/url" "reflect" "time" @@ -157,7 +158,30 @@ func (p GithubGraphql) PrepareTaskData(taskCtx plugin.TaskContext, options map[s src := oauth2.StaticTokenSource( &oauth2.Token{AccessToken: connection.GetToken()}, ) - httpClient := oauth2.NewClient(taskCtx.GetContext(), src) + oauthContext := taskCtx.GetContext() + proxy := connection.GetProxy() + if proxy != "" { + pu, err := url.Parse(proxy) + if err != nil { + return nil, errors.Convert(err) + } + if pu.Scheme == "http" || pu.Scheme == "socks5" { + proxyClient := &http.Client{ + Transport: &http.Transport{Proxy: http.ProxyURL(pu)}, + } + oauthContext = context.WithValue( + taskCtx.GetContext(), + oauth2.HTTPClient, + proxyClient, + ) + logger.Debug("Proxy set in oauthContext to %s", proxy) + } else { + return nil, errors.BadInput.New("Unsupported scheme set in proxy") + } + } + + + httpClient := oauth2.NewClient(oauthContext, src) endpoint, err := errors.Convert01(url.JoinPath(connection.Endpoint, `graphql`)) if err != nil { return nil, errors.BadInput.Wrap(err, fmt.Sprintf("malformed connection endpoint supplied: %s", connection.Endpoint))