Skip to content

Commit

Permalink
doghouse: do not share http client
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Jun 8, 2020
1 parent 601dde4 commit 9323c77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 8 additions & 2 deletions doghouse/appengine/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ import (
"net/url"
"strings"

"contrib.go.opencensus.io/exporter/stackdriver/propagation"
"github.com/reviewdog/reviewdog/doghouse"
"github.com/reviewdog/reviewdog/doghouse/server"
"github.com/reviewdog/reviewdog/doghouse/server/ciutil"
"github.com/reviewdog/reviewdog/doghouse/server/storage"
"go.opencensus.io/plugin/ochttp"
)

type githubChecker struct {
privateKey []byte
integrationID int
ghInstStore storage.GitHubInstallationStore
ghRepoTokenStore storage.GitHubRepositoryTokenStore
httpCli *http.Client
}

func (gc *githubChecker) handleCheck(w http.ResponseWriter, r *http.Request) {
Expand All @@ -46,7 +47,12 @@ func (gc *githubChecker) handleCheck(w http.ResponseWriter, r *http.Request) {
PrivateKey: gc.privateKey,
IntegrationID: gc.integrationID,
RepoOwner: req.Owner,
Client: gc.httpCli,
Client: &http.Client{
Transport: &ochttp.Transport{
// Use Google Cloud propagation format.
Propagation: &propagation.HTTPFormat{},
},
},
}

gh, err := server.NewGitHubClient(ctx, opt)
Expand Down
8 changes: 0 additions & 8 deletions doghouse/appengine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ func main() {
ghInstStore := storage.GitHubInstallationDatastore{}
ghRepoTokenStore := storage.GitHubRepoTokenDatastore{}

httpCli := &http.Client{
Transport: &ochttp.Transport{
// Use Google Cloud propagation format.
Propagation: &propagation.HTTPFormat{},
},
}

ghHandler := NewGitHubHandler(
mustGetenv("GITHUB_CLIENT_ID"),
mustGetenv("GITHUB_CLIENT_SECRET"),
Expand All @@ -93,7 +86,6 @@ func main() {
integrationID: integrationID,
ghInstStore: &ghInstStore,
ghRepoTokenStore: &ghRepoTokenStore,
httpCli: httpCli,
}

ghWebhookHandler := githubWebhookHandler{
Expand Down

0 comments on commit 9323c77

Please sign in to comment.