Skip to content

Commit

Permalink
pass in a new client to fix insecure call
Browse files Browse the repository at this point in the history
  • Loading branch information
bonifaido authored and orymate committed May 29, 2019
1 parent acaa7d1 commit d2ce78b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions cmd/pke/app/util/pipeline/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ func Client(out io.Writer, endpoint, token string, insecure bool) *pipeline.APIC
config := pipeline.NewConfiguration()
config.BasePath = endpoint
config.UserAgent = "pke/1.0.0/go"
config.HTTPClient = oauth2.NewClient(nil, oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: token},
))

if insecure {
config.HTTPClient.Transport = &http.Transport{
httpClient := http.Client{
Timeout: 24 * time.Hour,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
InsecureSkipVerify: insecure,
},
}
},
}
ctx := context.Background()
ctx = context.WithValue(ctx, oauth2.HTTPClient, &httpClient)

config.HTTPClient = oauth2.NewClient(ctx, oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: token},
))

// Since transport.NewRetryTransport is added, this timeout will affect only the cumulated retry calls.
config.HTTPClient.Timeout = 24 * time.Hour
tl := transport.NewLogger(out, config.HTTPClient.Transport)
config.HTTPClient.Transport = transport.NewRetryTransport(tl)

Expand Down

0 comments on commit d2ce78b

Please sign in to comment.