github.com/arunkumar7540/cli@v6.45.0+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  // ClearTarget clears target information from the actor.
     8  func (actor Actor) ClearTarget() {
     9  	actor.Config.SetTargetInformation("", "", "", "", "", "", false)
    10  	actor.Config.SetTokenInformation("", "", "")
    11  }
    12  
    13  // MinCLIVersion returns the minimum CLI version that the Cloud Controller
    14  // requires.
    15  func (actor Actor) MinCLIVersion() string {
    16  	return actor.CloudControllerClient.MinCLIVersion()
    17  }
    18  
    19  // SetTarget targets the Cloud Controller using the client and sets target
    20  // information in the actor based on the response.
    21  func (actor Actor) SetTarget(settings TargetSettings) (Warnings, error) {
    22  	if actor.Config.Target() == settings.URL && actor.Config.SkipSSLValidation() == settings.SkipSSLValidation {
    23  		return nil, nil
    24  	}
    25  
    26  	warnings, err := actor.CloudControllerClient.TargetCF(ccv2.TargetSettings(settings))
    27  	if err != nil {
    28  		return Warnings(warnings), err
    29  	}
    30  
    31  	actor.Config.SetTargetInformation(
    32  		actor.CloudControllerClient.API(),
    33  		actor.CloudControllerClient.APIVersion(),
    34  		actor.CloudControllerClient.AuthorizationEndpoint(),
    35  		actor.CloudControllerClient.MinCLIVersion(),
    36  		actor.CloudControllerClient.DopplerEndpoint(),
    37  		actor.CloudControllerClient.RoutingEndpoint(),
    38  		settings.SkipSSLValidation,
    39  	)
    40  	actor.Config.SetTokenInformation("", "", "")
    41  
    42  	return Warnings(warnings), nil
    43  }