github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/actor/v2action/stack.go (about)

     1  package v2action
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
     7  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccv2"
     8  )
     9  
    10  type Stack ccv2.Stack
    11  
    12  // StackNotFoundError is returned when a requested stack is not found.
    13  type StackNotFoundError struct {
    14  	GUID string
    15  }
    16  
    17  func (e StackNotFoundError) Error() string {
    18  	return fmt.Sprintf("Stack with GUID '%s' not found.", e.GUID)
    19  }
    20  
    21  // GetStack returns the stack information associated with the provided stack GUID.
    22  func (actor Actor) GetStack(guid string) (Stack, Warnings, error) {
    23  	stack, warnings, err := actor.CloudControllerClient.GetStack(guid)
    24  
    25  	if _, ok := err.(ccerror.ResourceNotFoundError); ok {
    26  		return Stack{}, Warnings(warnings), StackNotFoundError{GUID: guid}
    27  	}
    28  
    29  	return Stack(stack), Warnings(warnings), err
    30  }