Skip to content

Commit 1fa9f5f

Browse files
added option to inject http-client
added option to inject http-client
2 parents 1523907 + 8abb720 commit 1fa9f5f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pkg/codefresh/codefresh.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ type (
2424
)
2525

2626
func New(opt *ClientOptions) Codefresh {
27+
httpClient := &http.Client{}
28+
if opt.Client != nil {
29+
httpClient = opt.Client
30+
}
2731

2832
return &codefresh{
2933
host: opt.Host,
3034
token: opt.Auth.Token,
31-
client: &http.Client{},
35+
client: httpClient,
3236
}
3337
}
3438

pkg/codefresh/types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ type (
1212

1313
// Options
1414
ClientOptions struct {
15-
Auth AuthOptions
16-
Debug bool
17-
Host string
15+
Auth AuthOptions
16+
Debug bool
17+
Host string
18+
Client *http.Client
1819
}
1920

2021
codefresh struct {

0 commit comments

Comments
 (0)