github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/actor/v7action/target.go (about) 1 package v7action 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" 5 "code.cloudfoundry.org/cli/util/configv3" 6 ) 7 8 type TargetSettings ccv3.TargetSettings 9 10 // SetTarget targets the Cloud Controller using the client and sets target 11 // information in the config based on the response. 12 func (actor Actor) SetTarget(settings TargetSettings) (Warnings, error) { 13 var allWarnings Warnings 14 15 actor.CloudControllerClient.TargetCF(ccv3.TargetSettings(settings)) 16 17 rootInfo, warnings, err := actor.CloudControllerClient.GetInfo() 18 allWarnings = append(allWarnings, warnings...) 19 if err != nil { 20 return allWarnings, err 21 } 22 23 actor.Config.SetTargetInformation(configv3.TargetInformationArgs{ 24 Api: settings.URL, 25 ApiVersion: rootInfo.CloudControllerAPIVersion(), 26 Auth: rootInfo.Login(), 27 MinCLIVersion: "", // Oldest supported V3 version should be OK 28 Doppler: rootInfo.Logging(), 29 LogCache: rootInfo.LogCache(), 30 NetworkPolicyV1: rootInfo.NetworkPolicyV1(), 31 Routing: rootInfo.Routing(), 32 SkipSSLValidation: settings.SkipSSLValidation, 33 UAA: rootInfo.UAA(), 34 CFOnK8s: rootInfo.CFOnK8s, 35 }) 36 37 actor.Config.SetTokenInformation("", "", "") 38 actor.Config.SetKubernetesAuthInfo("") 39 40 return allWarnings, nil 41 } 42 43 // ClearTarget clears target information from the config. 44 func (actor Actor) ClearTarget() { 45 actor.Config.SetTargetInformation(configv3.TargetInformationArgs{}) 46 actor.Config.SetTokenInformation("", "", "") 47 actor.Config.SetKubernetesAuthInfo("") 48 }