github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/commands/application/get_health_check.go (about) 1 package application 2 3 import ( 4 "fmt" 5 6 "code.cloudfoundry.org/cli/cf/api/applications" 7 "code.cloudfoundry.org/cli/cf/flags" 8 . "code.cloudfoundry.org/cli/cf/i18n" 9 10 "code.cloudfoundry.org/cli/cf/commandregistry" 11 "code.cloudfoundry.org/cli/cf/configuration/coreconfig" 12 "code.cloudfoundry.org/cli/cf/requirements" 13 "code.cloudfoundry.org/cli/cf/terminal" 14 ) 15 16 type GetHealthCheck struct { 17 ui terminal.UI 18 config coreconfig.Reader 19 appReq requirements.ApplicationRequirement 20 appRepo applications.Repository 21 } 22 23 func init() { 24 commandregistry.Register(&GetHealthCheck{}) 25 } 26 27 func (cmd *GetHealthCheck) MetaData() commandregistry.CommandMetadata { 28 return commandregistry.CommandMetadata{ 29 Name: "get-health-check", 30 Description: T("Get the health_check_type value of an app"), 31 Usage: []string{ 32 T("CF_NAME get-health-check APP_NAME"), 33 }, 34 } 35 } 36 37 func (cmd *GetHealthCheck) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { 38 if len(fc.Args()) != 1 { 39 cmd.ui.Failed(T("Incorrect Usage. Requires APP_NAME as argument\n\n") + commandregistry.Commands.CommandUsage("get-health-check")) 40 return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) 41 } 42 43 cmd.ui.Say(T("Getting health_check_type value for ") + terminal.EntityNameColor(fc.Args()[0])) 44 cmd.ui.Say("") 45 46 cmd.appReq = requirementsFactory.NewApplicationRequirement(fc.Args()[0]) 47 48 reqs := []requirements.Requirement{ 49 requirementsFactory.NewLoginRequirement(), 50 requirementsFactory.NewTargetedSpaceRequirement(), 51 cmd.appReq, 52 } 53 54 return reqs, nil 55 } 56 57 func (cmd *GetHealthCheck) SetDependency(deps commandregistry.Dependency, pluginCall bool) commandregistry.Command { 58 cmd.ui = deps.UI 59 cmd.config = deps.Config 60 cmd.appRepo = deps.RepoLocator.GetApplicationRepository() 61 return cmd 62 } 63 64 func (cmd *GetHealthCheck) Execute(fc flags.FlagContext) error { 65 app := cmd.appReq.GetApplication() 66 67 cmd.ui.Say(T("health_check_type is ") + terminal.HeaderColor(app.HealthCheckType)) 68 return nil 69 }