Skip to content

Commit

Permalink
Merge pull request #1 from telia-oss/graphql-proxy-fix
Browse files Browse the repository at this point in the history
graphql-proxy-fix
  • Loading branch information
albinvass authored Jun 12, 2023
2 parents d09b36d + 8de7a7c commit 132c1c8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/plugins/github_graphql/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"fmt"
"net/url"
"net/http"
"reflect"
"time"

Expand Down Expand Up @@ -158,6 +159,17 @@ func (p GithubGraphql) PrepareTaskData(taskCtx plugin.TaskContext, options map[s
&oauth2.Token{AccessToken: connection.GetToken()},
)
httpClient := oauth2.NewClient(taskCtx.GetContext(), src)
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" {
httpClient.Transport.(*http.Transport).Proxy = http.ProxyURL(pu)
}
}

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))
Expand Down

0 comments on commit 132c1c8

Please sign in to comment.