forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application_instance.go
40 lines (29 loc) · 1.27 KB
/
application_instance.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package v2action
import (
"code.cloudfoundry.org/cli/actor/actionerror"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv2"
)
type ApplicationInstanceState ccv2.ApplicationInstanceState
type ApplicationInstance ccv2.ApplicationInstance
func (instance ApplicationInstance) Crashed() bool {
return instance.State == ccv2.ApplicationInstanceCrashed
}
func (instance ApplicationInstance) Flapping() bool {
return instance.State == ccv2.ApplicationInstanceFlapping
}
func (instance ApplicationInstance) Running() bool {
return instance.State == ccv2.ApplicationInstanceRunning
}
func (actor Actor) GetApplicationInstancesByApplication(guid string) (map[int]ApplicationInstance, Warnings, error) {
ccAppInstances, warnings, err := actor.CloudControllerClient.GetApplicationInstancesByApplication(guid)
switch err.(type) {
case ccerror.ResourceNotFoundError, ccerror.NotStagedError, ccerror.InstancesError:
return nil, Warnings(warnings), actionerror.ApplicationInstancesNotFoundError{ApplicationGUID: guid}
}
appInstances := map[int]ApplicationInstance{}
for id, applicationInstance := range ccAppInstances {
appInstances[id] = ApplicationInstance(applicationInstance)
}
return appInstances, Warnings(warnings), err
}