github.com/jcarley/cli@v0.0.0-20180201210820-966d90434c30/commands/redeploy/contract.go (about) 1 package redeploy 2 3 import ( 4 "github.com/Sirupsen/logrus" 5 "github.com/daticahealth/cli/commands/environments" 6 "github.com/daticahealth/cli/commands/services" 7 "github.com/daticahealth/cli/config" 8 "github.com/daticahealth/cli/lib/auth" 9 "github.com/daticahealth/cli/lib/jobs" 10 "github.com/daticahealth/cli/lib/prompts" 11 "github.com/daticahealth/cli/models" 12 "github.com/jault3/mow.cli" 13 ) 14 15 // Cmd is the contract between the user and the CLI. This specifies the command 16 // name, arguments, and required/optional arguments and flags for the command. 17 var Cmd = models.Command{ 18 Name: "redeploy", 19 ShortHelp: "Redeploy a service without having to do a git push. This will cause downtime for all redeploys (see the resources page for more details).", 20 LongHelp: "<code>redeploy</code> deploys an identical copy of the given service. " + 21 "For code services, this avoids having to perform a code push. You skip the git push and the build. " + 22 "For service proxies, new instances replace the old ones. " + 23 "All other service types cannot be redeployed with this command. " + 24 "For service proxy redeploys, there will be approximately 5 minutes of downtime. " + 25 "For code service redeploys, there will be approximately 30 seconds of downtime. " + 26 "Here is a sample command\n\n" + 27 "<pre>\ndatica -E \"<your_env_name>\" redeploy app01\n</pre>", 28 CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) { 29 return func(cmd *cli.Cmd) { 30 serviceName := cmd.StringArg("SERVICE_NAME", "", "The name of the service to redeploy (e.g. 'app01')") 31 cmd.Action = func() { 32 if _, err := auth.New(settings, prompts.New()).Signin(); err != nil { 33 logrus.Fatal(err.Error()) 34 } 35 if err := config.CheckRequiredAssociation(settings); err != nil { 36 logrus.Fatal(err.Error()) 37 } 38 err := CmdRedeploy(settings.EnvironmentID, *serviceName, jobs.New(settings), services.New(settings), environments.New(settings)) 39 if err != nil { 40 logrus.Fatal(err.Error()) 41 } 42 } 43 cmd.Spec = "SERVICE_NAME" 44 } 45 }, 46 }