github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+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  }
    44  
    45  func (actor Actor) AuthorizationEndpoint() string {
    46  	return actor.CloudControllerClient.AuthorizationEndpoint()
    47  }