@@ -4,10 +4,10 @@ import (
4
4
"context"
5
5
"crypto/tls"
6
6
"fmt"
7
- "net/http"
8
7
"net/url"
9
8
"strings"
10
9
10
+ "github.com/hashicorp/go-cleanhttp"
11
11
gitlab "gitlab.com/gitlab-org/api/client-go"
12
12
13
13
"github.com/akuity/kargo/internal/git"
@@ -75,33 +75,36 @@ func NewProvider(
75
75
if opts == nil {
76
76
opts = & gitprovider.Options {}
77
77
}
78
+
78
79
scheme , host , projectName , err := parseRepoURL (repoURL )
79
80
if err != nil {
80
81
return nil , err
81
82
}
83
+
82
84
clientOpts := make ([]gitlab.ClientOptionFunc , 0 , 2 )
85
+
83
86
if host != "gitlab.com" {
84
87
clientOpts = append (
85
88
clientOpts ,
86
89
gitlab .WithBaseURL (fmt .Sprintf ("%s://%s/api/v4" , scheme , host )),
87
90
)
88
91
}
92
+
93
+ httpClient := cleanhttp .DefaultClient ()
89
94
if opts .InsecureSkipTLSVerify {
90
- clientOpts = append (
91
- clientOpts ,
92
- gitlab .WithHTTPClient (& http.Client {
93
- Transport : & http.Transport {
94
- TLSClientConfig : & tls.Config {
95
- InsecureSkipVerify : true , // nolint: gosec
96
- },
97
- },
98
- }),
99
- )
95
+ transport := cleanhttp .DefaultTransport ()
96
+ transport .TLSClientConfig = & tls.Config {
97
+ InsecureSkipVerify : true , // nolint: gosec
98
+ }
99
+ httpClient .Transport = transport
100
100
}
101
+ clientOpts = append (clientOpts , gitlab .WithHTTPClient (httpClient ))
102
+
101
103
client , err := gitlab .NewClient (opts .Token , clientOpts ... )
102
104
if err != nil {
103
105
return nil , err
104
106
}
107
+
105
108
return & provider {
106
109
projectName : projectName ,
107
110
client : client .MergeRequests ,
0 commit comments