forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_client.go
32 lines (25 loc) · 947 Bytes
/
new_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package shared
import (
"code.cloudfoundry.org/cli/api/plugin"
"code.cloudfoundry.org/cli/api/plugin/wrapper"
"code.cloudfoundry.org/cli/command"
)
// NewClients creates a new V2 Cloud Controller client and UAA client using the
// passed in config.
func NewClient(config command.Config, ui command.UI, skipSSLValidation bool) *plugin.Client {
verbose, location := config.Verbose()
pluginClient := plugin.NewClient(plugin.Config{
AppName: config.BinaryName(),
AppVersion: config.BinaryVersion(),
DialTimeout: config.DialTimeout(),
SkipSSLValidation: skipSSLValidation,
})
if verbose {
pluginClient.WrapConnection(wrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay()))
}
if location != nil {
pluginClient.WrapConnection(wrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location)))
}
pluginClient.WrapConnection(wrapper.NewRetryRequest(config.RequestRetryCount()))
return pluginClient
}