()
| 35 | } |
| 36 | |
| 37 | func (c *Command) Run() error { |
| 38 | var err error |
| 39 | |
| 40 | appDirectory, err := c.globalFlags.GetApplicationDirectory() |
| 41 | if err != nil { |
| 42 | return err |
| 43 | } |
| 44 | |
| 45 | // AWS client |
| 46 | c.awsClient = c.globalFlags.GetAWSClient() |
| 47 | |
| 48 | if conv.B(c.commandFlags.Default) { |
| 49 | console.Info("Generating default configuration...") |
| 50 | } |
| 51 | |
| 52 | // default config |
| 53 | defConf := config.DefaultConfig(core.DefaultAppName(appDirectory)) |
| 54 | |
| 55 | conf := &config.Config{} |
| 56 | |
| 57 | // app name |
| 58 | conf.Name = conv.SP(c.askQuestion("Name of your application", "App Name", conv.S(defConf.Name))) |
| 59 | |
| 60 | // cluster name |
| 61 | conf.ClusterName = conv.SP(c.askQuestion("Name of the cluster your application will be deployed", "Cluster Name", conv.S(defConf.ClusterName))) |
| 62 | |
| 63 | // app port |
| 64 | input := c.askQuestion("Does your application expose TCP port? (Enter 0 if not)", "Port", fmt.Sprintf("%d", conv.U16(defConf.Port))) |
| 65 | parsed, err := strconv.ParseUint(input, 10, 16) |
| 66 | if err != nil { |
| 67 | return console.ExitWithErrorString("Invalid port number [%s]", input) |
| 68 | } |
| 69 | conf.Port = conv.U16P(uint16(parsed)) |
| 70 | |
| 71 | // cpu |
| 72 | input = c.askQuestion("CPU allocation per unit (1core = 1.0)", "CPU", fmt.Sprintf("%.2f", conv.F64(defConf.CPU))) |
| 73 | parsedF, err := strconv.ParseFloat(input, 64) |
| 74 | if err != nil { |
| 75 | return console.ExitWithErrorString("Invalid CPU [%s]", input) |
| 76 | } |
| 77 | conf.CPU = conv.F64P(parsedF) |
| 78 | |
| 79 | // Memory |
| 80 | conf.Memory = conv.SP(c.askQuestion("Memory allocation per unit", "Memory", conv.S(defConf.Memory))) |
| 81 | |
| 82 | // Units |
| 83 | input = c.askQuestion("Number of application units", "Units", fmt.Sprintf("%d", conv.U16(defConf.Units))) |
| 84 | parsed, err = strconv.ParseUint(input, 10, 16) |
| 85 | if err != nil { |
| 86 | return console.ExitWithErrorString("Invalid units [%s]", input) |
| 87 | } |
| 88 | conf.Units = conv.U16P(uint16(parsed)) |
| 89 | |
| 90 | // load balancer |
| 91 | if conv.B(c.commandFlags.Default) || console.AskConfirm("Does your application need load balancing?", true) { |
| 92 | conf.LoadBalancer.Enabled = conv.BP(true) |
| 93 | |
| 94 | // port |
nothing calls this directly
no test coverage detected