github.com/sleungcy-sap/cli@v7.1.0+incompatible/actor/v7action/target.go (about) 1 package v7action 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" 5 "code.cloudfoundry.org/cli/util/configv3" 6 ) 7 8 type TargetSettings ccv3.TargetSettings 9 10 // SetTarget targets the Cloud Controller using the client and sets target 11 // information in the actor based on the response. 12 func (actor Actor) SetTarget(settings TargetSettings) (Warnings, error) { 13 rootInfo, warnings, err := actor.CloudControllerClient.TargetCF(ccv3.TargetSettings(settings)) 14 if err != nil { 15 return Warnings(warnings), err 16 } 17 18 actor.Config.SetTargetInformation(configv3.TargetInformationArgs{ 19 Api: settings.URL, 20 ApiVersion: rootInfo.CloudControllerAPIVersion(), 21 Auth: rootInfo.Login(), 22 MinCLIVersion: "", // Oldest supported V3 version should be OK 23 Doppler: rootInfo.Logging(), 24 LogCache: rootInfo.LogCache(), 25 Routing: rootInfo.Routing(), 26 SkipSSLValidation: settings.SkipSSLValidation, 27 }) 28 actor.Config.SetTokenInformation("", "", "") 29 return Warnings(warnings), nil 30 } 31 32 // ClearTarget clears target information from the actor. 33 func (actor Actor) ClearTarget() { 34 actor.Config.SetTargetInformation(configv3.TargetInformationArgs{}) 35 actor.Config.SetTokenInformation("", "", "") 36 }