working commit

This commit is contained in:
2026-06-09 14:10:53 +02:00
parent ee30858d11
commit 6e92720e69
26 changed files with 339 additions and 165 deletions
+50
View File
@@ -0,0 +1,50 @@
/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*/
package grant
import (
"context"
"mbase/pkg/client"
"mbase/pkg/mbctl"
"github.com/spf13/cobra"
)
func (util *Util) SetGrant(cmd *cobra.Command, args []string) {
util.setGrantParams.Username = args[0]
util.setGrantParams.Grantname = args[1]
res, err := util.setGrant(util.setGrantParams)
printResponse(res, err)
}
type SetGrantParams struct {
Username string
Grantname string
}
type SetGrantResult struct {
GrantID string
}
func (util *Util) setGrant(params SetGrantParams) (SetGrantResult, error) {
var err error
res := SetGrantResult{}
grpcConn, cli, err := client.NewClient(&util.access)
if err != nil {
return res, err
}
defer grpcConn.Close()
operParams := &mbctl.SetGrantParams{
Username: params.Username,
Grantname: params.Grantname,
}
ctx := context.Background()
operRes, err := cli.SetGrant(ctx, operParams)
if err != nil {
return res, err
}
res.GrantID = operRes.GrantID
return res, err
}