Example #1
0
func appDelAction(c *cli.Context) {
	appname := c.String("d")
	super, err := context.CheckSuperPerm(context.Config.User)
	if err != nil {
		fmt.Println(err)
		return
	}
	if !super {
		fmt.Println("You have no permission to this operation")
		return
	}
	if appname == "" {
		appname = context.GetAppName()
	}

	fmt.Printf("Type %s to continue: ", "yes")
	var cmd string
	fmt.Scanf("%s\n", &cmd)
	if cmd != "yes" {
		return
	}
	_, version, err := context.GetApp(appname)
	if err != nil {
		fmt.Println(err)
		return
	}
	err = context.DelApp(appname, version)
	if err != nil {
		fmt.Println(err)
		return
	} else {
		fmt.Printf("Delete %s success\n", appname)
	}
}
Example #2
0
func appDelAction(c *cli.Context) {
	appname := context.GetAppName()

	fmt.Printf("Type %s to continue: ", "yes")
	var cmd string
	fmt.Scanf("%s\n", &cmd)
	if cmd != "yes" {
		return
	}
	_, version, err := context.GetApp(appname)
	if err != nil {
		fmt.Println(err)
		return
	}
	err = context.DelApp(appname, version)
	if err != nil {
		fmt.Println(err)
		return
	} else {
		fmt.Printf("Delete %s success\n", appname)
	}
}
Example #3
0
File: appmod.go Project: ketor/cc
func appModAction(c *cli.Context) {
	appname := context.GetAppName()
	s := c.String("s")
	m := c.String("m")
	f := c.String("f")
	i := c.Int("i")
	r := c.String("r")
	R := c.String("R")
	k := c.Int("k")
	t := c.Int("t")

	appConfig := meta.AppConfig{}
	config, version, err := context.GetApp(appname)
	if err != nil {
		fmt.Println(err)
		return
	}
	err = json.Unmarshal(config, &appConfig)
	if err != nil {
		fmt.Println(err)
		return
	}
	//update config if needed
	if s != "" {
		if s == "true" {
			appConfig.AutoEnableSlaveRead = true
		} else if s == "false" {
			appConfig.AutoEnableSlaveRead = false
		}
	}
	if m != "" {
		if m == "true" {
			appConfig.AutoEnableMasterWrite = true
		} else if m == "false" {
			appConfig.AutoEnableMasterWrite = false
		}
	}
	if f != "" {
		if f == "true" {
			appConfig.AutoFailover = true
		} else if f == "false" {
			appConfig.AutoFailover = false
		}
	}
	if i != -1 {
		appConfig.AutoFailoverInterval = time.Duration(i)
	}
	if r != "" {
		appConfig.MasterRegion = r
	}
	if R != "" {
		appConfig.Regions = strings.Split(R, ",")
	}
	if k != -1 {
		appConfig.MigrateKeysEachTime = k
	}
	if t != -1 {
		appConfig.MigrateTimeout = t
	}

	out, err := json.Marshal(appConfig)
	if err != nil {
		fmt.Println(err)
		return
	}
	err = context.ModApp(appname, out, version)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("Mod %s success\n%s\n", appname, string(out))
}