github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+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.RoutingEndpoint(),
    26  		settings.SkipSSLValidation,
    27  	)
    28  	config.SetTokenInformation("", "", "")
    29  
    30  	return Warnings(warnings), nil
    31  }
    32  
    33  // ClearTarget clears target information from the actor.
    34  func (Actor) ClearTarget(config Config) {
    35  	config.SetTargetInformation("", "", "", "", "", "", false)
    36  	config.SetTokenInformation("", "", "")
    37  }
    38  
    39  // ClearTarget clears the targeted org and space in the config.
    40  func (Actor) ClearOrganizationAndSpace(config Config) {
    41  	config.UnsetOrganizationInformation()
    42  	config.UnsetSpaceInformation()
    43  }