working commit
This commit is contained in:
+10
-10
@@ -21,7 +21,7 @@ import (
|
||||
"mstore/pkg/client"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
"mstore/pkg/auxid"
|
||||
)
|
||||
|
||||
func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
|
||||
@@ -117,7 +117,7 @@ type CreateGrantParams struct {
|
||||
Pattern string
|
||||
}
|
||||
type CreateGrantResult struct {
|
||||
GrantID uuid.UUID `yaml:"grantId"`
|
||||
GrantID uint64 `yaml:"grantId"`
|
||||
}
|
||||
|
||||
func (util *GrantUtil) CreateGrant(cmd *cobra.Command, args []string) {
|
||||
@@ -140,9 +140,9 @@ func (util *GrantUtil) createGrant(common *CommonGrantParams, params *CreateGran
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
re := regexp.MustCompile(uuidRegex)
|
||||
id := strings.ToLower(params.AccountID)
|
||||
var operRes uuid.UUID
|
||||
var operRes uint64
|
||||
if re.MatchString(id) {
|
||||
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, uuid.UUID(id), term.Right(params.Right), params.Pattern)
|
||||
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, uint64(id), term.Right(params.Right), params.Pattern)
|
||||
} else {
|
||||
operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, term.Right(params.Right), params.Pattern)
|
||||
}
|
||||
@@ -178,7 +178,7 @@ func (util *GrantUtil) updateGrant(common *CommonGrantParams, params *UpdateGran
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
id := strings.ToLower(params.GrantID)
|
||||
err = client.NewClient().UpdateGrant(ctx, hostname, uuid.UUID(id), params.Pattern)
|
||||
err = client.NewClient().UpdateGrant(ctx, hostname, uint64(id), params.Pattern)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func (util *GrantUtil) getGrant(common *CommonGrantParams, params *GetGrantParam
|
||||
opRes := &descr.Grant{}
|
||||
|
||||
id := strings.ToLower(params.GrantID)
|
||||
opRes, err = client.NewClient().GetGrant(ctx, hostname, uuid.UUID(id))
|
||||
opRes, err = client.NewClient().GetGrant(ctx, hostname, uint64(id))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -245,7 +245,7 @@ func (util *GrantUtil) deleteGrant(common *CommonGrantParams, params *DeleteGran
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
id := strings.ToLower(params.GrantID)
|
||||
err = client.NewClient().DeleteGrant(ctx, hostname, uuid.UUID(id))
|
||||
err = client.NewClient().DeleteGrant(ctx, hostname, uint64(id))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -260,7 +260,7 @@ type ListGrantsParams struct {
|
||||
|
||||
type ListGrantsResult struct {
|
||||
Grants []descr.Grant `yaml:"grants,omitempty"`
|
||||
Rights map[uuid.UUID]term.Right `yaml:"rights,omitempty"`
|
||||
Rights map[uint64]term.Right `yaml:"rights,omitempty"`
|
||||
}
|
||||
|
||||
func (util *GrantUtil) ListGrants(cmd *cobra.Command, args []string) {
|
||||
@@ -282,7 +282,7 @@ func (util *GrantUtil) listGrants(common *CommonGrantParams, params *ListGrantsP
|
||||
re := regexp.MustCompile(uuidRegex)
|
||||
id := strings.ToLower(params.AccountID)
|
||||
if re.MatchString(id) {
|
||||
grants, err = client.NewClient().ListGrantsByAccountID(ctx, hostname, uuid.UUID(id))
|
||||
grants, err = client.NewClient().ListGrantsByAccountID(ctx, hostname, uint64(id))
|
||||
} else {
|
||||
grants, err = client.NewClient().ListGrantsByUsername(ctx, hostname, params.AccountID)
|
||||
}
|
||||
@@ -292,7 +292,7 @@ func (util *GrantUtil) listGrants(common *CommonGrantParams, params *ListGrantsP
|
||||
if params.Detail {
|
||||
res.Grants = grants
|
||||
} else {
|
||||
res.Rights = make(map[uuid.UUID]term.Right, 0)
|
||||
res.Rights = make(map[uint64]term.Right, 0)
|
||||
for _, item := range grants {
|
||||
res.Rights[item.ID] = item.Right
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user