github.com/loafoe/cli@v7.1.0+incompatible/cf/requirements/dea_application.go (about) 1 package requirements 2 3 import ( 4 "code.cloudfoundry.org/cli/cf/api/applications" 5 "code.cloudfoundry.org/cli/cf/errors" 6 "code.cloudfoundry.org/cli/cf/models" 7 "code.cloudfoundry.org/cli/cf/terminal" 8 ) 9 10 //go:generate counterfeiter . DEAApplicationRequirement 11 12 type DEAApplicationRequirement interface { 13 Requirement 14 GetApplication() models.Application 15 } 16 17 type deaApplicationRequirement struct { 18 appName string 19 ui terminal.UI 20 appRepo applications.Repository 21 22 application models.Application 23 } 24 25 func NewDEAApplicationRequirement(name string, applicationRepo applications.Repository) DEAApplicationRequirement { 26 return &deaApplicationRequirement{ 27 appName: name, 28 appRepo: applicationRepo, 29 } 30 } 31 32 func (req *deaApplicationRequirement) Execute() error { 33 app, err := req.appRepo.Read(req.appName) 34 if err != nil { 35 return err 36 } 37 38 if app.Diego == true { 39 return errors.New("The app is running on the Diego backend, which does not support this command.") 40 } 41 42 req.application = app 43 44 return nil 45 } 46 47 func (req *deaApplicationRequirement) GetApplication() models.Application { 48 return req.application 49 }