@@ -14,7 +14,6 @@ import (
1414 "github.com/bradleyfalzon/ghinstallation/v2"
1515 giturls "github.com/chainguard-dev/git-urls"
1616 "github.com/google/go-github/v69/github"
17- log "github.com/sirupsen/logrus"
1817 "github.com/spf13/cast"
1918
2019 httputil "github.com/argoproj/notifications-engine/pkg/util/http"
@@ -400,33 +399,28 @@ func NewGitHubService(opts GitHubOptions) (*gitHubService, error) {
400399 return nil , err
401400 }
402401
403- var idleConnTimeout time.Duration
404- if opts .IdleConnTimeout != "" {
405- idleConnTimeout , err = time .ParseDuration (opts .IdleConnTimeout )
406- if err != nil {
407- return nil , fmt .Errorf ("failed to parse idle connection timeout: %w" , err )
408- }
402+ client , err := httputil .NewServiceHTTPClient (opts .MaxIdleConns , opts .MaxIdleConnsPerHost , opts .MaxConnsPerHost , opts .IdleConnTimeout , opts .InsecureSkipVerify , url , "github" )
403+ if err != nil {
404+ return nil , err
409405 }
410- tr := httputil .NewLoggingRoundTripper (
411- httputil .NewTransport (url , opts .MaxIdleConns , opts .MaxIdleConnsPerHost , opts .MaxConnsPerHost , idleConnTimeout , false ), log .WithField ("service" , "github" ))
412- itr , err := ghinstallation .New (tr , appID , installationID , []byte (opts .PrivateKey ))
406+ itr , err := ghinstallation .New (client .Transport , appID , installationID , []byte (opts .PrivateKey ))
413407 if err != nil {
414408 return nil , err
415409 }
416410
417- var client * github.Client
411+ var ghclient * github.Client
418412 if opts .EnterpriseBaseURL == "" {
419- client = github .NewClient (& http.Client {Transport : itr })
413+ ghclient = github .NewClient (& http.Client {Transport : itr })
420414 } else {
421415 itr .BaseURL = opts .EnterpriseBaseURL
422- client , err = github .NewClient (& http.Client {Transport : itr }).WithEnterpriseURLs (opts .EnterpriseBaseURL , "" )
416+ ghclient , err = github .NewClient (& http.Client {Transport : itr }).WithEnterpriseURLs (opts .EnterpriseBaseURL , "" )
423417 if err != nil {
424418 return nil , err
425419 }
426420 }
427421
428422 return & gitHubService {
429- client : & githubClientAdapter {client : client },
423+ client : & githubClientAdapter {client : ghclient },
430424 }, nil
431425}
432426
0 commit comments