github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/actor/v2action/target.go (about) 1 package v2action 2 3 import "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2" 4 5 type TargetSettings ccv2.TargetSettings 6 7 // SetTarget targets the Cloud Controller using the client and sets target 8 // information in the actor based on the response. 9 func (actor Actor) SetTarget(config Config, settings TargetSettings) (Warnings, error) { 10 if config.Target() == settings.URL && config.SkipSSLValidation() == settings.SkipSSLValidation { 11 return nil, nil 12 } 13 14 warnings, err := actor.CloudControllerClient.TargetCF(ccv2.TargetSettings(settings)) 15 if err != nil { 16 return Warnings(warnings), err 17 } 18 19 config.SetTargetInformation( 20 actor.CloudControllerClient.API(), 21 actor.CloudControllerClient.APIVersion(), 22 actor.CloudControllerClient.AuthorizationEndpoint(), 23 actor.CloudControllerClient.MinCLIVersion(), 24 actor.CloudControllerClient.DopplerEndpoint(), 25 actor.CloudControllerClient.TokenEndpoint(), 26 actor.CloudControllerClient.RoutingEndpoint(), 27 settings.SkipSSLValidation, 28 ) 29 config.SetTokenInformation("", "", "") 30 31 return Warnings(warnings), nil 32 } 33 34 // ClearTarget clears target information from the actor. 35 func (_ Actor) ClearTarget(config Config) { 36 config.SetTargetInformation("", "", "", "", "", "", "", false) 37 config.SetTokenInformation("", "", "") 38 } 39 40 // ClearTarget clears the targeted org and space in the config. 41 func (_ Actor) ClearOrganizationAndSpace(config Config) { 42 config.UnsetOrganizationInformation() 43 config.UnsetSpaceInformation() 44 }