github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/api/plugin/client.go (about) 1 package plugin 2 3 import ( 4 "fmt" 5 "runtime" 6 "time" 7 ) 8 9 // Client is a client that can be used to make HTTP requests to plugin 10 // repositories. 11 type Client struct { 12 connection Connection 13 userAgent string 14 } 15 16 // Config allows the Client to be configured 17 type Config struct { 18 // AppName is the name of the application/process using the client. 19 AppName string 20 21 // AppVersion is the version of the application/process using the client. 22 AppVersion string 23 24 // DialTimeout is the DNS lookup timeout for the client. If not set, it is 25 // infinite. 26 DialTimeout time.Duration 27 28 // SkipSSLValidation controls whether a client verifies the server's 29 // certificate chain and host name. If SkipSSLValidation is true, TLS accepts 30 // any certificate presented by the server and any host name in that 31 // certificate for *all* client requests going forward. 32 // 33 // In this mode, TLS is susceptible to man-in-the-middle attacks. This should 34 // be used only for testing. 35 SkipSSLValidation bool 36 } 37 38 // NewClient returns a new plugin Client. 39 func NewClient(config Config) *Client { 40 userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", 41 config.AppName, 42 config.AppVersion, 43 runtime.Version(), 44 runtime.GOARCH, 45 runtime.GOOS, 46 ) 47 client := Client{ 48 userAgent: userAgent, 49 connection: NewConnection(config.SkipSSLValidation, config.DialTimeout), 50 } 51 52 return &client 53 }