github.com/jcarley/cli@v0.0.0-20180201210820-966d90434c30/commands/rollback/contract.go (about) 1 package rollback 2 3 import ( 4 "github.com/Sirupsen/logrus" 5 "github.com/daticahealth/cli/commands/releases" 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: "rollback", 19 ShortHelp: "Rollback a code service to a specific release", 20 LongHelp: "<code>rollback</code> is a way to redeploy older versions of your code service. " + 21 "You must specify the name of the service to rollback and the name of an existing release to rollback to. " + 22 "Releases can be found with the releases list command. Here are some sample commands\n\n" + 23 "<pre>\ndatica -E \"<your_env_name>\" rollback code-1 f93ced037f828dcaabccfc825e6d8d32cc5a1883\n</pre>", 24 CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) { 25 return func(cmd *cli.Cmd) { 26 serviceName := cmd.StringArg("SERVICE_NAME", "", "The name of the service to rollback") 27 releaseName := cmd.StringArg("RELEASE_NAME", "", "The name of the release to rollback to") 28 cmd.Action = func() { 29 if _, err := auth.New(settings, prompts.New()).Signin(); err != nil { 30 logrus.Fatal(err.Error()) 31 } 32 if err := config.CheckRequiredAssociation(settings); err != nil { 33 logrus.Fatal(err.Error()) 34 } 35 err := CmdRollback(*serviceName, *releaseName, jobs.New(settings), releases.New(settings), services.New(settings)) 36 if err != nil { 37 logrus.Fatal(err.Error()) 38 } 39 } 40 cmd.Spec = "SERVICE_NAME RELEASE_NAME" 41 } 42 }, 43 }