working commit
This commit is contained in:
@@ -4,20 +4,40 @@
|
||||
package grant
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mbase/pkg/mbctl"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func (util *Util) DeleteGrant(cmd *cobra.Command, args []string) {
|
||||
//util.deleteGrantParams.Filename = args[0]
|
||||
res, err := util.deleteGrant(util.deleteGrantParams)
|
||||
util.deleteGrantParams.Username = args[0]
|
||||
util.deleteGrantParams.Operation = args[1]
|
||||
res, err := util.deleteGrant(&util.deleteGrantParams)
|
||||
printResponse(res, err)
|
||||
}
|
||||
|
||||
type deleteGrantParams struct{}
|
||||
type deleteGrantResult struct{}
|
||||
type DeleteGrantParams struct {
|
||||
Username string
|
||||
Operation string
|
||||
}
|
||||
type DeleteGrantResult struct {
|
||||
GrantID string `json:"grantId"`
|
||||
}
|
||||
|
||||
func (util *Util) deleteGrant(params deleteGrantParams) (deleteGrantResult, error) {
|
||||
func (util *Util) deleteGrant(params *DeleteGrantParams) (*DeleteGrantResult, error) {
|
||||
var err error
|
||||
res := deleteGrantResult{}
|
||||
res := &DeleteGrantResult{}
|
||||
ctx := context.Background()
|
||||
operParams := &mbctl.SetGrantParams{
|
||||
Username: params.Username,
|
||||
Operation: params.Operation,
|
||||
}
|
||||
operRes, err := util.oper.SetGrant(ctx, util.operID, operParams)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.GrantID = operRes.GrantID
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user