github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/actor/v3action/droplet.go (about) 1 package v3action 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" 5 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" 6 ) 7 8 // Droplet represents a Cloud Controller droplet. 9 type Droplet struct { 10 GUID string 11 Stack string 12 Buildpacks []Buildpack 13 } 14 15 type Buildpack ccv3.Buildpack 16 17 // AssignDropletError is returned when assigning the current droplet of an app 18 // fails 19 type AssignDropletError struct { 20 } 21 22 func (a AssignDropletError) Error() string { 23 return "Unable to assign current droplet. Ensure the droplet exists and belongs to this app." 24 } 25 26 // SetApplicationDroplet sets the droplet for an application. 27 func (actor Actor) SetApplicationDroplet(appName string, spaceGUID string, dropletGUID string) (Warnings, error) { 28 allWarnings := Warnings{} 29 application, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) 30 allWarnings = append(allWarnings, warnings...) 31 if err != nil { 32 return allWarnings, err 33 } 34 _, apiWarnings, err := actor.CloudControllerClient.SetApplicationDroplet(application.GUID, dropletGUID) 35 actorWarnings := Warnings(apiWarnings) 36 allWarnings = append(allWarnings, actorWarnings...) 37 38 if _, ok := err.(ccerror.UnprocessableEntityError); ok { 39 return allWarnings, AssignDropletError{} 40 } 41 42 return allWarnings, err 43 }