1 Star 0 Fork 0

ryancartoon/sensu-go

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
remove_group.go 835 Bytes
Copy Edit Raw Blame History
Cyril Cressent authored 2018-11-24 02:19 +08:00 . Complete redesign of RBAC (#2338)
package user
import (
"errors"
"fmt"
"github.com/sensu/sensu-go/cli"
"github.com/spf13/cobra"
)
// RemoveGroupCommand adds a command that allows admins to remove a group from a user.
func RemoveGroupCommand(cli *cli.SensuCli) *cobra.Command {
return &cobra.Command{
Use: "remove-group [USERNAME] [group]",
Short: "remove group from user given username and group",
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
// If no name is present print out usage
if len(args) != 2 {
_ = cmd.Help()
return errors.New("invalid argument(s) received")
}
username := args[0]
group := args[1]
if err := cli.Client.RemoveGroupFromUser(username, group); err != nil {
return err
}
_, err := fmt.Fprintln(cmd.OutOrStdout(), "Removed")
return err
},
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ryancartoon/sensu-go.git
git@gitee.com:ryancartoon/sensu-go.git
ryancartoon
sensu-go
sensu-go
v5.10.1

Search