github.com/liamawhite/cli-with-i18n@v6.32.1-0.20171122084555-dede0a5c3448+incompatible/actor/v3action/process.go (about)

     1  package v3action
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/liamawhite/cli-with-i18n/api/cloudcontroller/ccerror"
     7  	"github.com/liamawhite/cli-with-i18n/api/cloudcontroller/ccv3"
     8  )
     9  
    10  // Process represents a V3 actor process.
    11  type Process ccv3.Process
    12  
    13  // ProcessNotFoundError is returned when the proccess type cannot be found
    14  type ProcessNotFoundError struct {
    15  	ProcessType string
    16  }
    17  
    18  func (e ProcessNotFoundError) Error() string {
    19  	return fmt.Sprintf("Process %s not found", e.ProcessType)
    20  }
    21  
    22  func (actor Actor) ScaleProcessByApplication(appGUID string, process Process) (Warnings, error) {
    23  	warnings, err := actor.CloudControllerClient.CreateApplicationProcessScale(appGUID, ccv3.Process(process))
    24  	allWarnings := Warnings(warnings)
    25  	if err != nil {
    26  		if _, ok := err.(ccerror.ProcessNotFoundError); ok {
    27  			return allWarnings, ProcessNotFoundError{ProcessType: process.Type}
    28  		}
    29  		return allWarnings, err
    30  	}
    31  
    32  	return allWarnings, nil
    33  }