github.com/swisscom/cloudfoundry-cli@v7.1.0+incompatible/api/cloudcontroller/ccv3/target.go (about) 1 package ccv3 2 3 import ( 4 "time" 5 ) 6 7 // TargetSettings represents configuration for establishing a connection to the 8 // Cloud Controller server. 9 type TargetSettings struct { 10 // DialTimeout is the DNS timeout used to make all requests to the Cloud 11 // Controller. 12 DialTimeout time.Duration 13 14 // SkipSSLValidation controls whether a client verifies the server's 15 // certificate chain and host name. If SkipSSLValidation is true, TLS accepts 16 // any certificate presented by the server and any host name in that 17 // certificate for *all* client requests going forward. 18 // 19 // In this mode, TLS is susceptible to man-in-the-middle attacks. This should 20 // be used only for testing. 21 SkipSSLValidation bool 22 23 // URL is a fully qualified URL to the Cloud Controller API. 24 URL string 25 } 26 27 // TargetCF sets the client to use the Cloud Controller specified in the 28 // configuration. Any other configuration is also applied to the client. 29 func (client *Client) TargetCF(settings TargetSettings) (Info, Warnings, error) { 30 client.CloudControllerURL = settings.URL 31 client.InitializeConnection(settings) 32 33 rootInfo, resourceLinks, warnings, err := client.GetInfo() 34 if err != nil { 35 return Info{}, warnings, err 36 } 37 38 client.Info = rootInfo 39 40 resources := map[string]string{} 41 for resource, link := range resourceLinks { 42 resources[resource] = link.HREF 43 } 44 client.InitializeRouter(resources) 45 46 return rootInfo, warnings, nil 47 }