working commit
This commit is contained in:
+12
-12
@@ -24,7 +24,7 @@ import (
|
||||
func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
|
||||
var subCmd = &cobra.Command{
|
||||
Use: "grants",
|
||||
Short: "Grant operation",
|
||||
Short: "Grant operations",
|
||||
Aliases: []string{"grant"},
|
||||
}
|
||||
const defaultTimeout uint64 = 10
|
||||
@@ -35,7 +35,7 @@ func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
|
||||
|
||||
// CreateGrant
|
||||
var createGrantCmd = &cobra.Command{
|
||||
Use: "create hostname[:port] username|accountId rigth pattern",
|
||||
Use: "create [user:pass@]hostname[:port] username|accountId rigth pattern",
|
||||
Short: "Create grant",
|
||||
Args: cobra.ExactArgs(4),
|
||||
Run: util.CreateGrant,
|
||||
@@ -44,7 +44,7 @@ func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
|
||||
|
||||
// GetGrant
|
||||
var getGrantCmd = &cobra.Command{
|
||||
Use: "get hostname[:port] grantId",
|
||||
Use: "get [user:pass@]hostname[:port] grantId",
|
||||
Short: "Get detail grant info",
|
||||
Args: cobra.ExactArgs(2),
|
||||
Run: util.GetGrant,
|
||||
@@ -53,16 +53,16 @@ func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
|
||||
|
||||
// UpdateGrant
|
||||
var updateGrantCmd = &cobra.Command{
|
||||
Use: "update hostname[:port] gruntId newPattern",
|
||||
Use: "update [user:pass@]hostname[:port] gruntId newPattern",
|
||||
Short: "Update grant parameters",
|
||||
Args: cobra.ExactArgs(3),
|
||||
Run: util.UpdateGrant,
|
||||
Run: util.UpdateGrant,
|
||||
}
|
||||
subCmd.AddCommand(updateGrantCmd)
|
||||
|
||||
// DeleteGrant
|
||||
var deleteGrantCmd = &cobra.Command{
|
||||
Use: "delete hostname[:port] gruntId ",
|
||||
Use: "delete [user:pass@]hostname[:port] gruntId ",
|
||||
Short: "Delete grant",
|
||||
Args: cobra.ExactArgs(2),
|
||||
|
||||
@@ -72,9 +72,9 @@ func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
|
||||
|
||||
// ListGrants
|
||||
var listGrantsCmd = &cobra.Command{
|
||||
Use: "list hostname[:port] accountId|username",
|
||||
Use: "list [user:pass@]hostname[:port] accountId|username",
|
||||
Short: "list user grants",
|
||||
Args: cobra.ExactArgs(2),
|
||||
Args: cobra.ExactArgs(2),
|
||||
Run: util.ListGrants,
|
||||
}
|
||||
listGrantsCmd.Flags().BoolVarP(&util.listGrantsParams.Detail, "detail", "d", false, "Show detail information")
|
||||
@@ -128,9 +128,9 @@ func (util *GrantUtil) createGrant(common *CommonGrantParams, params *CreateGran
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
re := regexp.MustCompile(uuidRegex)
|
||||
re := regexp.MustCompile(uuidRegex)
|
||||
id := strings.ToLower(params.AccountID)
|
||||
var operRes string
|
||||
var operRes string
|
||||
if re.MatchString(id) {
|
||||
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, params.AccountID, params.Right, params.Pattern)
|
||||
} else {
|
||||
@@ -249,8 +249,8 @@ type ListGrantsParams struct {
|
||||
}
|
||||
|
||||
type ListGrantsResult struct {
|
||||
Grants []descr.Grant `yaml:"grants,omitempty"`
|
||||
Rights map[string]string `yaml:"rights,omitempty"`
|
||||
Grants []descr.Grant `yaml:"grants,omitempty"`
|
||||
Rights map[string]string `yaml:"rights,omitempty"`
|
||||
}
|
||||
|
||||
func (util *GrantUtil) ListGrants(cmd *cobra.Command, args []string) {
|
||||
|
||||
Reference in New Issue
Block a user