github.com/lukasheimann/cloudfoundrycli@v7.1.0+incompatible/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  )
     8  
     9  type Deployment ccv3.Deployment
    10  
    11  func (actor Actor) CreateDeploymentByApplicationAndDroplet(appGUID string, dropletGUID string) (string, Warnings, error) {
    12  	deploymentGUID, warnings, err := actor.CloudControllerClient.CreateApplicationDeployment(appGUID, dropletGUID)
    13  
    14  	return deploymentGUID, Warnings(warnings), err
    15  }
    16  
    17  func (actor Actor) CreateDeploymentByApplicationAndRevision(appGUID string, revisionGUID string) (string, Warnings, error) {
    18  	deploymentGUID, warnings, _ := actor.CloudControllerClient.CreateApplicationDeploymentByRevision(appGUID, revisionGUID)
    19  
    20  	return deploymentGUID, Warnings(warnings), nil
    21  }
    22  
    23  func (actor Actor) GetLatestActiveDeploymentForApp(appGUID string) (Deployment, Warnings, error) {
    24  	ccDeployments, warnings, err := actor.CloudControllerClient.GetDeployments(
    25  		ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{appGUID}},
    26  		ccv3.Query{Key: ccv3.StatusValueFilter, Values: []string{string(constant.DeploymentStatusValueActive)}},
    27  		ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.CreatedAtDescendingOrder}},
    28  		ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}},
    29  	)
    30  
    31  	if err != nil {
    32  		return Deployment{}, Warnings(warnings), err
    33  	}
    34  
    35  	if len(ccDeployments) == 0 {
    36  		return Deployment{}, Warnings(warnings), actionerror.ActiveDeploymentNotFoundError{}
    37  	}
    38  
    39  	return 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  }