github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+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(settings TargetSettings) (Warnings, error) {
    10  	if actor.Config.Target() == settings.URL && actor.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  	actor.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  	actor.Config.SetTokenInformation("", "", "")
    29  
    30  	return Warnings(warnings), nil
    31  }
    32  
    33  // ClearTarget clears target information from the actor.
    34  func (actor Actor) ClearTarget() {
    35  	actor.Config.SetTargetInformation("", "", "", "", "", "", false)
    36  	actor.Config.SetTokenInformation("", "", "")
    37  }