forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dea_application.go
49 lines (38 loc) · 1.08 KB
/
dea_application.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
41
42
43
44
45
46
47
48
49
package requirements
import (
"code.cloudfoundry.org/cli/cf/api/applications"
"code.cloudfoundry.org/cli/cf/errors"
"code.cloudfoundry.org/cli/cf/models"
"code.cloudfoundry.org/cli/cf/terminal"
)
//go:generate counterfeiter . DEAApplicationRequirement
type DEAApplicationRequirement interface {
Requirement
GetApplication() models.Application
}
type deaApplicationRequirement struct {
appName string
ui terminal.UI
appRepo applications.Repository
application models.Application
}
func NewDEAApplicationRequirement(name string, applicationRepo applications.Repository) DEAApplicationRequirement {
return &deaApplicationRequirement{
appName: name,
appRepo: applicationRepo,
}
}
func (req *deaApplicationRequirement) Execute() error {
app, err := req.appRepo.Read(req.appName)
if err != nil {
return err
}
if app.Diego == true {
return errors.New("The app is running on the Diego backend, which does not support this command.")
}
req.application = app
return nil
}
func (req *deaApplicationRequirement) GetApplication() models.Application {
return req.application
}