github.com/sleungcy-sap/cli@v7.1.0+incompatible/actor/v2action/target.go (about) 1 package v2action 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2" 5 6 "code.cloudfoundry.org/cli/util/configv3" 7 ) 8 9 type TargetSettings ccv2.TargetSettings 10 11 // ClearTarget clears target information from the actor. 12 func (actor Actor) ClearTarget() { 13 actor.Config.SetTargetInformation(configv3.TargetInformationArgs{}) 14 actor.Config.SetTokenInformation("", "", "") 15 } 16 17 // MinCLIVersion returns the minimum CLI version that the Cloud Controller 18 // requires. 19 func (actor Actor) MinCLIVersion() string { 20 return actor.CloudControllerClient.MinCLIVersion() 21 } 22 23 // SetTarget targets the Cloud Controller using the client and sets target 24 // information in the actor based on the response. 25 func (actor Actor) SetTarget(settings TargetSettings) (Warnings, error) { 26 if actor.Config.Target() == settings.URL && actor.Config.SkipSSLValidation() == settings.SkipSSLValidation { 27 return nil, nil 28 } 29 30 warnings, err := actor.CloudControllerClient.TargetCF(ccv2.TargetSettings(settings)) 31 if err != nil { 32 return Warnings(warnings), err 33 } 34 35 actor.Config.SetTargetInformation(configv3.TargetInformationArgs{ 36 Api: actor.CloudControllerClient.API(), 37 ApiVersion: actor.CloudControllerClient.APIVersion(), 38 Auth: actor.CloudControllerClient.AuthorizationEndpoint(), 39 MinCLIVersion: actor.CloudControllerClient.MinCLIVersion(), 40 Doppler: actor.CloudControllerClient.DopplerEndpoint(), 41 LogCache: actor.CloudControllerClient.LogCacheEndpoint(), 42 Routing: actor.CloudControllerClient.RoutingEndpoint(), 43 SkipSSLValidation: settings.SkipSSLValidation, 44 }) 45 actor.Config.SetTokenInformation("", "", "") 46 47 return Warnings(warnings), nil 48 } 49 50 func (actor Actor) AuthorizationEndpoint() string { 51 return actor.CloudControllerClient.AuthorizationEndpoint() 52 }