forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.go
43 lines (35 loc) · 985 Bytes
/
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
package requirements
import (
"github.com/cloudfoundry/cli/cf/api/applications"
"github.com/cloudfoundry/cli/cf/models"
"github.com/cloudfoundry/cli/cf/terminal"
)
type ApplicationRequirement interface {
Requirement
GetApplication() models.Application
}
type applicationApiRequirement struct {
name string
ui terminal.UI
appRepo applications.ApplicationRepository
application models.Application
}
func NewApplicationRequirement(name string, ui terminal.UI, aR applications.ApplicationRepository) *applicationApiRequirement {
req := &applicationApiRequirement{}
req.name = name
req.ui = ui
req.appRepo = aR
return req
}
func (req *applicationApiRequirement) Execute() (success bool) {
var apiErr error
req.application, apiErr = req.appRepo.Read(req.name)
if apiErr != nil {
req.ui.Failed(apiErr.Error())
return false
}
return true
}
func (req *applicationApiRequirement) GetApplication() models.Application {
return req.application
}