コード例 #1
0
ファイル: userdel.go プロジェクト: ksarch-saas/cc
func userDelAction(c *cli.Context) {
	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
	}

	username := c.String("u")

	fmt.Printf("Type %s to continue: ", "yes")
	var cmd string
	fmt.Scanf("%s\n", &cmd)
	if cmd != "yes" {
		return
	}
	_, version, err := context.GetUser(username)
	if err != nil {
		fmt.Println(err)
		return
	}
	err = context.DelUser(username, version)
	if err != nil {
		fmt.Println(err)
		return
	} else {
		fmt.Printf("Delete %s success\n", username)
	}
}
コード例 #2
0
ファイル: appdel.go プロジェクト: ksarch-saas/cc
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)
	}
}
コード例 #3
0
ファイル: useradd.go プロジェクト: ksarch-saas/cc
func userAddAction(c *cli.Context) {
	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
	}

	username := c.String("u")
	role := c.String("r")

	if username == "" {
		fmt.Println("-u,username must be assigned")
		return
	}

	token, err := context.AddUser(username, role)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("Add %s success\nToken:%s\n", username, token)
}