func createGroup(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 1) { return } wait, _ := cmd.Flags().GetBool(WAIT_FLAG) force, _ := cmd.Flags().GetBool(FORCE_FLAG) params, _ := cmd.Flags().GetStringSlice(PARAMS_FLAG) ignore, _ := cmd.Flags().GetBool(IGNORE_MISSING) options := &marathon.CreateOptions{Wait: wait, Force: force, ErrorOnMissingParams: !ignore} if params != nil { envmap := make(map[string]string) for _, p := range params { if strings.Contains(p, "=") { v := strings.Split(p, "=") envmap[v[0]] = v[1] } } options.EnvParams = envmap } result, e := client(cmd).CreateGroupFromFile(args[0], options) if e != nil && e == marathon.ErrorGroupExists { cli.Output(nil, fmt.Errorf("%s, consider using the --force flag to update when group exists", e.Error())) return } cli.Output(AppGroup{result}, e) }
func createApp(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 1) { return } wait, _ := cmd.Flags().GetBool(WAIT_FLAG) force, _ := cmd.Flags().GetBool(FORCE_FLAG) paramsFile, _ := cmd.Flags().GetString(ENV_FILE_FLAG) params, _ := cmd.Flags().GetStringSlice(PARAMS_FLAG) ignore, _ := cmd.Flags().GetBool(IGNORE_MISSING) options := &marathon.CreateOptions{Wait: wait, Force: force, ErrorOnMissingParams: !ignore} if paramsFile != "" { envParams, _ := parseParamsFile(paramsFile) options.EnvParams = envParams } else { options.EnvParams = make(map[string]string) } if params != nil { for _, p := range params { if strings.Contains(p, "=") { v := strings.Split(p, "=") options.EnvParams[v[0]] = v[1] } } } result, e := client(cmd).CreateApplicationFromFile(args[0], options) if e != nil && e == marathon.ErrorAppExists { cli.Output(nil, errors.New(fmt.Sprintf("%s, consider using the --force flag to update when an application exists", e.Error()))) return } cli.Output(Application{result}, e) }
func destroyGroup(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 1) { return } v, e := client(cmd).DestroyGroup(args[0]) cli.Output(DeploymentId{v}, e) }
func appKillTask(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 1) { return } scale, _ := cmd.Flags().GetBool(SCALE_FLAG) v, e := client(cmd).KillAppTask(args[0], scale) cli.Output(Task{v}, e) }
func getGroup(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 1) { return } v, e := client(cmd).GetGroup(args[0]) cli.Output(AppGroup{v}, e) }
func destroyApp(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 1) { return } v, e := client(cmd).DestroyApplication(args[0]) cli.Output(DeploymentId{v}, e) waitForDeploymentIfFlagged(cmd, v.DeploymentID) }
func convertFile(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 2) { return } if err := encoding.ConvertFile(args[0], args[1], &marathon.Application{}); err != nil { cli.Output(nil, err) return } fmt.Printf("Source file %s has been re-written into new format in %s\n\n", args[0], args[1]) }
func appKillAllTasks(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 1) { return } host, _ := cmd.Flags().GetString(HOST_FLAG) scale, _ := cmd.Flags().GetBool(SCALE_FLAG) v, e := client(cmd).KillAppTasks(args[0], host, scale) cli.Output(&Tasks{Tasks: v}, e) }
func rollbackAppVersion(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 2) { return } wait, _ := cmd.Flags().GetBool(WAIT_FLAG) update := marathon.NewApplication(args[0]).RollbackVersion(args[1]) v, e := client(cmd).UpdateApplication(update, wait) cli.Output(Application{v}, e) }
func restartApp(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 1) { return } force, _ := cmd.Flags().GetBool(FORCE_FLAG) v, e := client(cmd).RestartApplication(args[0], force) cli.Output(DeploymentId{v}, e) waitForDeploymentIfFlagged(cmd, v.DeploymentID) }
func scaleApp(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 2) { return } instances, err := strconv.Atoi(args[1]) if err != nil { cli.Output(nil, err) return } v, e := client(cmd).ScaleApplication(args[0], instances) cli.Output(DeploymentId{v}, e) waitForDeploymentIfFlagged(cmd, v.DeploymentID) }
func updateAppMemory(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 2) { return } wait, _ := cmd.Flags().GetBool(WAIT_FLAG) mem, err := strconv.ParseFloat(args[1], 64) if err != nil { cli.Output(nil, err) return } update := marathon.NewApplication(args[0]).Memory(mem) v, e := client(cmd).UpdateApplication(update, wait) cli.Output(Application{v}, e) }
func appTasks(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 1) { return } detailed, _ := cmd.Flags().GetBool(DETAIL_FLAG) v, e := client(cmd).GetTasks(args[0]) if detailed && e == nil { fmt.Println("") for _, t := range v { fmt.Printf("::: Task: %s\n\n", t.ID) cli.Output(&Task{t}, e) } } else { cli.Output(&Tasks{Tasks: v}, e) } }
See config's subcommands for available choices`, } var configEnvCmd = &cobra.Command{ Use: "env", Short: "Configuration environments define remote Marathon and other supported services by a name. ", Long: `Manage configuration environments (eg. default, list, adding and removing of environments) See env's subcommands for available choices`, } var configRemoveCmd = &cobra.Command{ Use: "delete [name]", Short: "Remove a defined environment by it's [name]", Run: func(cmd *cobra.Command, args []string) { if cli.EvalPrintUsage(cmd.Usage, args, 1) { return } _, err := configFile.GetEnvironment(args[0]) if err != nil { cli.Output(nil, err) } else { err := configFile.RemoveEnvironment(args[0], false) if err != nil { cli.Output(nil, err) } } }, } var configAddCmd = &cobra.Command{