github.com/loafoe/cli@v7.1.0+incompatible/command/v7/set_health_check_command.go (about) 1 package v7 2 3 import ( 4 "code.cloudfoundry.org/cli/command/flag" 5 ) 6 7 type SetHealthCheckCommand struct { 8 BaseCommand 9 10 RequiredArgs flag.SetHealthCheckArgs `positional-args:"yes"` 11 HTTPEndpoint string `long:"endpoint" default:"/" description:"Path on the app"` 12 InvocationTimeout flag.PositiveInteger `long:"invocation-timeout" description:"Time (in seconds) that controls individual health check invocations"` 13 ProcessType string `long:"process" default:"web" description:"App process to update"` 14 usage interface{} `usage:"CF_NAME set-health-check APP_NAME (process | port | http [--endpoint PATH]) [--process PROCESS] [--invocation-timeout INVOCATION_TIMEOUT]\n\nEXAMPLES:\n cf set-health-check worker-app process --process worker\n cf set-health-check my-web-app http --endpoint /foo\n cf set-health-check my-web-app http --invocation-timeout 10"` 15 } 16 17 func (cmd SetHealthCheckCommand) Execute(args []string) error { 18 err := cmd.SharedActor.CheckTarget(true, true) 19 if err != nil { 20 return err 21 } 22 23 user, err := cmd.Config.CurrentUser() 24 if err != nil { 25 return err 26 } 27 28 cmd.UI.DisplayTextWithFlavor("Updating health check type for app {{.AppName}} process {{.ProcessType}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{ 29 "AppName": cmd.RequiredArgs.AppName, 30 "ProcessType": cmd.ProcessType, 31 "OrgName": cmd.Config.TargetedOrganization().Name, 32 "SpaceName": cmd.Config.TargetedSpace().Name, 33 "Username": user.Name, 34 }) 35 cmd.UI.DisplayNewline() 36 37 app, warnings, err := cmd.Actor.SetApplicationProcessHealthCheckTypeByNameAndSpace( 38 cmd.RequiredArgs.AppName, 39 cmd.Config.TargetedSpace().GUID, 40 cmd.RequiredArgs.HealthCheck.Type, 41 cmd.HTTPEndpoint, 42 cmd.ProcessType, 43 cmd.InvocationTimeout.Value, 44 ) 45 46 cmd.UI.DisplayWarnings(warnings) 47 if err != nil { 48 return err 49 } 50 51 cmd.UI.DisplayOK() 52 53 if app.Started() { 54 cmd.UI.DisplayText("TIP: An app restart is required for the change to take effect.") 55 } 56 57 return nil 58 }