github.com/DaAlbrecht/cf-cli@v0.0.0-20231128151943-1fe19bb400b9/actor/v7action/deployment.go (about) 1 package v7action 2 3 import ( 4 "code.cloudfoundry.org/cli/actor/actionerror" 5 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" 6 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" 7 "code.cloudfoundry.org/cli/resources" 8 ) 9 10 func (actor Actor) CreateDeploymentByApplicationAndDroplet(appGUID string, dropletGUID string) (string, Warnings, error) { 11 deploymentGUID, warnings, err := actor.CloudControllerClient.CreateApplicationDeployment(appGUID, dropletGUID) 12 13 return deploymentGUID, Warnings(warnings), err 14 } 15 16 func (actor Actor) CreateDeploymentByApplicationAndRevision(appGUID string, revisionGUID string) (string, Warnings, error) { 17 deploymentGUID, warnings, err := actor.CloudControllerClient.CreateApplicationDeploymentByRevision(appGUID, revisionGUID) 18 19 return deploymentGUID, Warnings(warnings), err 20 } 21 22 func (actor Actor) GetLatestActiveDeploymentForApp(appGUID string) (resources.Deployment, Warnings, error) { 23 ccDeployments, warnings, err := actor.CloudControllerClient.GetDeployments( 24 ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{appGUID}}, 25 ccv3.Query{Key: ccv3.StatusValueFilter, Values: []string{string(constant.DeploymentStatusValueActive)}}, 26 ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.CreatedAtDescendingOrder}}, 27 ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, 28 ) 29 30 if err != nil { 31 return resources.Deployment{}, Warnings(warnings), err 32 } 33 34 if len(ccDeployments) == 0 { 35 return resources.Deployment{}, Warnings(warnings), actionerror.ActiveDeploymentNotFoundError{} 36 } 37 38 return resources.Deployment(ccDeployments[0]), Warnings(warnings), nil 39 } 40 41 func (actor Actor) CancelDeployment(deploymentGUID string) (Warnings, error) { 42 warnings, err := actor.CloudControllerClient.CancelDeployment(deploymentGUID) 43 return Warnings(warnings), err 44 }