github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/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  		ccv3.Query{Key: ccv3.Page, Values: []string{"1"}},
    29  	)
    30  
    31  	if err != nil {
    32  		return resources.Deployment{}, Warnings(warnings), err
    33  	}
    34  
    35  	if len(ccDeployments) == 0 {
    36  		return resources.Deployment{}, Warnings(warnings), actionerror.ActiveDeploymentNotFoundError{}
    37  	}
    38  
    39  	return resources.Deployment(ccDeployments[0]), Warnings(warnings), nil
    40  }
    41  
    42  func (actor Actor) CancelDeployment(deploymentGUID string) (Warnings, error) {
    43  	warnings, err := actor.CloudControllerClient.CancelDeployment(deploymentGUID)
    44  	return Warnings(warnings), err
    45  }