github.com/lukasheimann/cloudfoundrycli@v7.1.0+incompatible/actor/v7action/revisions.go (about)

     1  package v7action
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
     5  	"code.cloudfoundry.org/cli/resources"
     6  )
     7  
     8  // GetRevisionsByApplicationNameAndSpace returns revisions for application.
     9  func (actor *Actor) GetRevisionsByApplicationNameAndSpace(appName string, spaceGUID string) ([]resources.Revision, Warnings, error) {
    10  	app, warnings, appErr := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
    11  	if appErr != nil {
    12  		return []resources.Revision{}, warnings, appErr
    13  	}
    14  	revisions, v3Warnings, apiErr := actor.CloudControllerClient.GetApplicationRevisions(
    15  		app.GUID,
    16  		ccv3.Query{Key: ccv3.OrderBy, Values: []string{"-created_at"}},
    17  	)
    18  	warnings = append(warnings, v3Warnings...)
    19  	if apiErr != nil {
    20  		return []resources.Revision{}, warnings, apiErr
    21  	}
    22  
    23  	return revisions, warnings, nil
    24  }
    25  
    26  func (actor Actor) GetRevisionByApplicationAndVersion(appGUID string, revisionVersion int) (resources.Revision, Warnings, error) {
    27  	revisions, warnings, _ := actor.CloudControllerClient.GetApplicationRevisions(appGUID)
    28  
    29  	for _, revision := range revisions {
    30  		if revision.Version == revisionVersion {
    31  			return revision, Warnings(warnings), nil
    32  		}
    33  	}
    34  	return resources.Revision{}, Warnings(warnings), nil
    35  }