working commit

This commit is contained in:
2026-02-20 19:08:26 +02:00
parent f973293315
commit 3220e2d78f
32 changed files with 195 additions and 213 deletions
+10 -10
View File
@@ -21,7 +21,7 @@ import (
"mstore/pkg/client"
"mstore/pkg/descr"
"mstore/pkg/term"
"mstore/pkg/uuid"
"mstore/pkg/auxid"
)
const (
@@ -126,8 +126,8 @@ type CreateAccountParams struct {
NewPassword string
}
type CreateAccountResult struct {
AccountID uuid.UUID `yaml:"accountId"`
Grants map[uuid.UUID]term.Right `yaml:"grantsIds,omitempty"`
AccountID uint64 `yaml:"accountId"`
Grants map[uint64]term.Right `yaml:"grantsIds,omitempty"`
}
func (util *AccountUtil) CreateAccount(cmd *cobra.Command, args []string) {
@@ -141,7 +141,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[uuid.UUID]term.Right, 0),
Grants: make(map[uint64]term.Right, 0),
}
hostname, err := packUserinfo(common.Hostname, common.Username, common.Password)
if err != nil {
@@ -203,7 +203,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, uuid.UUID(id), params.NewUsername, params.NewPassword)
err = client.NewClient().UpdateAccountByID(ctx, hostname, uint64(id), params.NewUsername, params.NewPassword)
} else {
err = client.NewClient().UpdateAccountByName(ctx, hostname, params.AccountID, params.NewUsername, params.NewPassword)
}
@@ -244,7 +244,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, uuid.UUID(id))
opRes, err = client.NewClient().GetAccountByID(ctx, hostname, uint64(id))
} else {
opRes, err = client.NewClient().GetAccountByName(ctx, hostname, params.AccountID)
}
@@ -281,7 +281,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, uuid.UUID(id))
err = client.NewClient().DeleteAccountByID(ctx, hostname, uint64(id))
} else {
err = client.NewClient().DeleteAccountByName(ctx, hostname, params.AccountID)
}
@@ -300,8 +300,8 @@ type ListAccountsParams struct {
type Userinfo struct {
Username string `yaml:"username,omitempty"`
AccountID uuid.UUID `yaml:"accountId,omitempty"`
Rights map[uuid.UUID]term.Right `yaml:"rights,omitempty"`
AccountID uint64 `yaml:"accountId,omitempty"`
Rights map[uint64]term.Right `yaml:"rights,omitempty"`
}
type ListAccountsResult struct {
@@ -350,7 +350,7 @@ func (util *AccountUtil) listAccounts(common *CommonAccountParams, params *ListA
userinfo := Userinfo{
Username: account.Username,
AccountID: account.ID,
Rights: make(map[uuid.UUID]term.Right, 0),
Rights: make(map[uint64]term.Right, 0),
}
for _, grant := range account.Grants {
userinfo.Rights[grant.ID] = grant.Right