working commit

This commit is contained in:
2026-06-07 18:19:15 +02:00
parent d3556d397c
commit 0506b35cd1
26 changed files with 199 additions and 1299 deletions
+43
View File
@@ -0,0 +1,43 @@
/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*/
package grant
import (
"context"
"mbase/pkg/mbctl"
"github.com/spf13/cobra"
)
func (util *Util) SetGrant(cmd *cobra.Command, args []string) {
util.setGrantParams.Username = args[0]
util.setGrantParams.Operation = args[1]
res, err := util.setGrant(&util.setGrantParams)
printResponse(res, err)
}
type SetGrantParams struct {
Username string
Operation string
}
type SetGrantResult struct {
GrantID string `json:"grantId"`
}
func (util *Util) setGrant(params *SetGrantParams) (*SetGrantResult, error) {
var err error
res := &SetGrantResult{}
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
}