working commit

This commit is contained in:
2026-02-21 12:31:39 +02:00
parent 3220e2d78f
commit cd37a4508c
37 changed files with 354 additions and 319 deletions
+11 -12
View File
@@ -21,7 +21,6 @@ import (
"mstore/pkg/client"
"mstore/pkg/descr"
"mstore/pkg/term"
"mstore/pkg/auxid"
)
const (
@@ -126,8 +125,8 @@ type CreateAccountParams struct {
NewPassword string
}
type CreateAccountResult struct {
AccountID uint64 `yaml:"accountId"`
Grants map[uint64]term.Right `yaml:"grantsIds,omitempty"`
AccountID string `yaml:"accountId"`
Grants map[string]string `yaml:"grantsIds,omitempty"`
}
func (util *AccountUtil) CreateAccount(cmd *cobra.Command, args []string) {
@@ -141,7 +140,7 @@ func (util *AccountUtil) CreateAccount(cmd *cobra.Command, args []string) {
func (util *AccountUtil) createAccount(common *CommonAccountParams, params *CreateAccountParams) (*CreateAccountResult, error) {
var err error
res := &CreateAccountResult{
Grants: make(map[uint64]term.Right, 0),
Grants: make(map[string]string, 0),
}
hostname, err := packUserinfo(common.Hostname, common.Username, common.Password)
if err != nil {
@@ -154,7 +153,7 @@ func (util *AccountUtil) createAccount(common *CommonAccountParams, params *Crea
return res, err
}
fullRights := []term.Right{
fullRights := []string{
term.RightWriteAccounts,
term.RightReadAccounts,
term.RightWriteFiles,
@@ -203,7 +202,7 @@ func (util *AccountUtil) updateAccount(common *CommonAccountParams, params *Upda
re := regexp.MustCompile(uuidRegex)
id := strings.ToLower(params.AccountID)
if re.MatchString(id) {
err = client.NewClient().UpdateAccountByID(ctx, hostname, uint64(id), params.NewUsername, params.NewPassword)
err = client.NewClient().UpdateAccountByID(ctx, hostname, id, params.NewUsername, params.NewPassword)
} else {
err = client.NewClient().UpdateAccountByName(ctx, hostname, params.AccountID, params.NewUsername, params.NewPassword)
}
@@ -244,7 +243,7 @@ func (util *AccountUtil) getAccount(common *CommonAccountParams, params *GetAcco
re := regexp.MustCompile(uuidRegex)
id := strings.ToLower(params.AccountID)
if re.MatchString(id) {
opRes, err = client.NewClient().GetAccountByID(ctx, hostname, uint64(id))
opRes, err = client.NewClient().GetAccountByID(ctx, hostname, id)
} else {
opRes, err = client.NewClient().GetAccountByName(ctx, hostname, params.AccountID)
}
@@ -281,7 +280,7 @@ func (util *AccountUtil) deleteAccount(common *CommonAccountParams, params *Dele
re := regexp.MustCompile(uuidRegex)
id := strings.ToLower(params.AccountID)
if re.MatchString(id) {
err = client.NewClient().DeleteAccountByID(ctx, hostname, uint64(id))
err = client.NewClient().DeleteAccountByID(ctx, hostname, id)
} else {
err = client.NewClient().DeleteAccountByName(ctx, hostname, params.AccountID)
}
@@ -299,9 +298,9 @@ type ListAccountsParams struct {
}
type Userinfo struct {
Username string `yaml:"username,omitempty"`
AccountID uint64 `yaml:"accountId,omitempty"`
Rights map[uint64]term.Right `yaml:"rights,omitempty"`
Username string `yaml:"username,omitempty"`
AccountID string `yaml:"accountId,omitempty"`
Rights map[string]string `yaml:"rights,omitempty"`
}
type ListAccountsResult struct {
@@ -350,7 +349,7 @@ func (util *AccountUtil) listAccounts(common *CommonAccountParams, params *ListA
userinfo := Userinfo{
Username: account.Username,
AccountID: account.ID,
Rights: make(map[uint64]term.Right, 0),
Rights: make(map[string]string, 0),
}
for _, grant := range account.Grants {
userinfo.Rights[grant.ID] = grant.Right