Skip to content

Commit

Permalink
fix gitea client timeout (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
nimakaviani authored May 16, 2024
1 parent 3fa0784 commit 1ed5422
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pkg/controllers/gitrepository/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ func GetGitProvider(ctx context.Context, repo *v1alpha1.GitRepository, kubeClien
case v1alpha1.GitProviderGitea:
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
DialContext: (&net.Dialer{
Timeout: gitTCPTimeout,
KeepAlive: 30 * time.Second, // from http.DefaultTransport
}).DialContext,
}
c := &http.Client{Transport: tr}
c := &http.Client{Transport: tr, Timeout: gitHTTPTimeout}
giteaClient, err := NewGiteaClient(repo.Spec.Provider.GitURL, gitea.SetHTTPClient(c))
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/gitrepository/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (g *giteaProvider) setProviderCredentials(ctx context.Context, repo *v1alph
func (g *giteaProvider) getRepository(ctx context.Context, repo *v1alpha1.GitRepository) (repoInfo, error) {
resp, repoResp, err := g.giteaClient.GetRepo(getOrganizationName(*repo), getRepositoryName(*repo))
if err != nil {
if repoResp.StatusCode == 404 {
if repoResp != nil && repoResp.StatusCode == 404 {
return repoInfo{}, notFoundError{}
}
return repoInfo{}, err
Expand Down

0 comments on commit 1ed5422

Please sign in to comment.