working commit
This commit is contained in:
+15
-15
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
"mstore/pkg/client"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -126,8 +126,8 @@ type CreateAccountParams struct {
|
||||
NewPassword string
|
||||
}
|
||||
type CreateAccountResult struct {
|
||||
AccountID uuid.UUID `yaml:"accountId"`
|
||||
Grants map[uuid.UUID]terms.Right `yaml:"grantsIds,omitempty"`
|
||||
AccountID uuid.UUID `yaml:"accountId"`
|
||||
Grants map[uuid.UUID]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]terms.Right, 0),
|
||||
Grants: make(map[uuid.UUID]term.Right, 0),
|
||||
}
|
||||
hostname, err := packUserinfo(common.Hostname, common.Username, common.Password)
|
||||
if err != nil {
|
||||
@@ -154,13 +154,13 @@ func (util *AccountUtil) createAccount(common *CommonAccountParams, params *Crea
|
||||
return res, err
|
||||
}
|
||||
|
||||
fullRights := []terms.Right{
|
||||
terms.RightWriteAccounts,
|
||||
terms.RightReadAccounts,
|
||||
terms.RightWriteFiles,
|
||||
terms.RightReadFiles,
|
||||
terms.RightWriteImages,
|
||||
terms.RightReadImages,
|
||||
fullRights := []term.Right{
|
||||
term.RightWriteAccounts,
|
||||
term.RightReadAccounts,
|
||||
term.RightWriteFiles,
|
||||
term.RightReadFiles,
|
||||
term.RightWriteImages,
|
||||
term.RightReadImages,
|
||||
}
|
||||
for _, right := range fullRights {
|
||||
id, err := client.NewClient().CreateGrantByAccountID(ctx, hostname, accountID, right, ".*")
|
||||
@@ -299,9 +299,9 @@ type ListAccountsParams struct {
|
||||
}
|
||||
|
||||
type Userinfo struct {
|
||||
Username string `yaml:"username,omitempty"`
|
||||
AccountID uuid.UUID `yaml:"accountId,omitempty"`
|
||||
Rights map[uuid.UUID]terms.Right `yaml:"rights,omitempty"`
|
||||
Username string `yaml:"username,omitempty"`
|
||||
AccountID uuid.UUID `yaml:"accountId,omitempty"`
|
||||
Rights map[uuid.UUID]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]terms.Right, 0),
|
||||
Rights: make(map[uuid.UUID]term.Right, 0),
|
||||
}
|
||||
for _, grant := range account.Grants {
|
||||
userinfo.Rights[grant.ID] = grant.Right
|
||||
|
||||
+16
-16
@@ -27,7 +27,7 @@ import (
|
||||
|
||||
"mstore/pkg/client"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
)
|
||||
|
||||
func (util *FileUtil) CreateFileCmds() *cobra.Command {
|
||||
@@ -338,14 +338,14 @@ func (util *FileUtil) listFiles(common *CommonFileParams, params *ListFilesParam
|
||||
if params.AsRegexp {
|
||||
params.AsPrefix = false
|
||||
}
|
||||
var pathAs terms.PathUsage
|
||||
var pathAs term.PathUsage
|
||||
switch {
|
||||
case params.AsRegexp:
|
||||
pathAs = terms.AsRegexp
|
||||
pathAs = term.AsRegexp
|
||||
case params.AsPrefix:
|
||||
pathAs = terms.AsPrefix
|
||||
pathAs = term.AsPrefix
|
||||
default:
|
||||
pathAs = terms.AsFinePath
|
||||
pathAs = term.AsFinePath
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
@@ -464,14 +464,14 @@ func (util *FileUtil) exportFiles(common *CommonFileParams, params *ExportFilesP
|
||||
if params.AsRegexp {
|
||||
params.AsPrefix = false
|
||||
}
|
||||
var pathAs terms.PathUsage
|
||||
var pathAs term.PathUsage
|
||||
switch {
|
||||
case params.AsRegexp:
|
||||
pathAs = terms.AsRegexp
|
||||
pathAs = term.AsRegexp
|
||||
case params.AsPrefix:
|
||||
pathAs = terms.AsPrefix
|
||||
pathAs = term.AsPrefix
|
||||
default:
|
||||
pathAs = terms.AsFinePath
|
||||
pathAs = term.AsFinePath
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
@@ -553,14 +553,14 @@ func (util *FileUtil) listCollections(common *CommonFileParams, params *ListColl
|
||||
if params.AsRegexp {
|
||||
params.AsPrefix = false
|
||||
}
|
||||
var pathAs terms.PathUsage
|
||||
var pathAs term.PathUsage
|
||||
switch {
|
||||
case params.AsRegexp:
|
||||
pathAs = terms.AsRegexp
|
||||
pathAs = term.AsRegexp
|
||||
case params.AsPrefix:
|
||||
pathAs = terms.AsPrefix
|
||||
pathAs = term.AsPrefix
|
||||
default:
|
||||
pathAs = terms.AsFinePath
|
||||
pathAs = term.AsFinePath
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
@@ -603,12 +603,12 @@ func (util *FileUtil) deleteCollection(common *CommonFileParams, params *DeleteC
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
var pathAs terms.PathUsage
|
||||
var pathAs term.PathUsage
|
||||
switch {
|
||||
case params.AsPrefix:
|
||||
pathAs = terms.AsPrefix
|
||||
pathAs = term.AsPrefix
|
||||
default:
|
||||
pathAs = terms.AsFinePath
|
||||
pathAs = term.AsFinePath
|
||||
}
|
||||
files, err := client.NewClient().DeleteCollection(ctx, params.Path, pathAs, params.DryRun)
|
||||
if err != nil {
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
"mstore/pkg/client"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -142,9 +142,9 @@ func (util *GrantUtil) createGrant(common *CommonGrantParams, params *CreateGran
|
||||
id := strings.ToLower(params.AccountID)
|
||||
var operRes uuid.UUID
|
||||
if re.MatchString(id) {
|
||||
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, uuid.UUID(id), terms.Right(params.Right), params.Pattern)
|
||||
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, uuid.UUID(id), term.Right(params.Right), params.Pattern)
|
||||
} else {
|
||||
operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, terms.Right(params.Right), params.Pattern)
|
||||
operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, term.Right(params.Right), params.Pattern)
|
||||
}
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -259,8 +259,8 @@ type ListGrantsParams struct {
|
||||
}
|
||||
|
||||
type ListGrantsResult struct {
|
||||
Grants []descr.Grant `yaml:"grants,omitempty"`
|
||||
Rights map[uuid.UUID]terms.Right `yaml:"rights,omitempty"`
|
||||
Grants []descr.Grant `yaml:"grants,omitempty"`
|
||||
Rights map[uuid.UUID]term.Right `yaml:"rights,omitempty"`
|
||||
}
|
||||
|
||||
func (util *GrantUtil) ListGrants(cmd *cobra.Command, args []string) {
|
||||
@@ -292,7 +292,7 @@ func (util *GrantUtil) listGrants(common *CommonGrantParams, params *ListGrantsP
|
||||
if params.Detail {
|
||||
res.Grants = grants
|
||||
} else {
|
||||
res.Rights = make(map[uuid.UUID]terms.Right, 0)
|
||||
res.Rights = make(map[uuid.UUID]term.Right, 0)
|
||||
for _, item := range grants {
|
||||
res.Rights[item.ID] = item.Right
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user