right type used

This commit is contained in:
2026-02-20 15:29:26 +02:00
parent 1c8f6f142c
commit 09f2125a4e
14 changed files with 121 additions and 138 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ EXTRA_mstored_SOURCES = \
pkg/auxtool/tmpfile.go \ pkg/auxtool/tmpfile.go \
pkg/auxtool/unixnow.go \ pkg/auxtool/unixnow.go \
pkg/auxutar/utar.go \ pkg/auxutar/utar.go \
pkg/auxuuid/uuid.go \ pkg/uuid/uuid.go \
pkg/auxx509/x509cert.go \ pkg/auxx509/x509cert.go \
pkg/client/account.go \ pkg/client/account.go \
pkg/client/client.go \ pkg/client/client.go \
+1 -1
View File
@@ -385,7 +385,7 @@ EXTRA_mstored_SOURCES = \
pkg/auxtool/tmpfile.go \ pkg/auxtool/tmpfile.go \
pkg/auxtool/unixnow.go \ pkg/auxtool/unixnow.go \
pkg/auxutar/utar.go \ pkg/auxutar/utar.go \
pkg/auxuuid/uuid.go \ pkg/uuid/uuid.go \
pkg/auxx509/x509cert.go \ pkg/auxx509/x509cert.go \
pkg/client/account.go \ pkg/client/account.go \
pkg/client/client.go \ pkg/client/client.go \
+12 -12
View File
@@ -18,10 +18,10 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"mstore/pkg/auxuuid"
"mstore/pkg/client" "mstore/pkg/client"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms" "mstore/pkg/terms"
"mstore/pkg/uuid"
) )
const ( const (
@@ -126,8 +126,8 @@ type CreateAccountParams struct {
NewPassword string NewPassword string
} }
type CreateAccountResult struct { type CreateAccountResult struct {
AccountID auxuuid.UUID `yaml:"accountId"` AccountID uuid.UUID `yaml:"accountId"`
Grants map[auxuuid.UUID]string `yaml:"grantsIds,omitempty"` Grants map[uuid.UUID]terms.Right `yaml:"grantsIds,omitempty"`
} }
func (util *AccountUtil) CreateAccount(cmd *cobra.Command, args []string) { 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) { func (util *AccountUtil) createAccount(common *CommonAccountParams, params *CreateAccountParams) (*CreateAccountResult, error) {
var err error var err error
res := &CreateAccountResult{ res := &CreateAccountResult{
Grants: make(map[auxuuid.UUID]string, 0), Grants: make(map[uuid.UUID]terms.Right, 0),
} }
hostname, err := packUserinfo(common.Hostname, common.Username, common.Password) hostname, err := packUserinfo(common.Hostname, common.Username, common.Password)
if err != nil { if err != nil {
@@ -154,7 +154,7 @@ func (util *AccountUtil) createAccount(common *CommonAccountParams, params *Crea
return res, err return res, err
} }
fullRights := []string{ fullRights := []terms.Right{
terms.RightWriteAccounts, terms.RightWriteAccounts,
terms.RightReadAccounts, terms.RightReadAccounts,
terms.RightWriteFiles, terms.RightWriteFiles,
@@ -203,7 +203,7 @@ func (util *AccountUtil) updateAccount(common *CommonAccountParams, params *Upda
re := regexp.MustCompile(uuidRegex) re := regexp.MustCompile(uuidRegex)
id := strings.ToLower(params.AccountID) id := strings.ToLower(params.AccountID)
if re.MatchString(id) { if re.MatchString(id) {
err = client.NewClient().UpdateAccountByID(ctx, hostname, auxuuid.UUID(id), params.NewUsername, params.NewPassword) err = client.NewClient().UpdateAccountByID(ctx, hostname, uuid.UUID(id), params.NewUsername, params.NewPassword)
} else { } else {
err = client.NewClient().UpdateAccountByName(ctx, hostname, params.AccountID, params.NewUsername, params.NewPassword) 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) re := regexp.MustCompile(uuidRegex)
id := strings.ToLower(params.AccountID) id := strings.ToLower(params.AccountID)
if re.MatchString(id) { if re.MatchString(id) {
opRes, err = client.NewClient().GetAccountByID(ctx, hostname, auxuuid.UUID(id)) opRes, err = client.NewClient().GetAccountByID(ctx, hostname, uuid.UUID(id))
} else { } else {
opRes, err = client.NewClient().GetAccountByName(ctx, hostname, params.AccountID) 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) re := regexp.MustCompile(uuidRegex)
id := strings.ToLower(params.AccountID) id := strings.ToLower(params.AccountID)
if re.MatchString(id) { if re.MatchString(id) {
err = client.NewClient().DeleteAccountByID(ctx, hostname, auxuuid.UUID(id)) err = client.NewClient().DeleteAccountByID(ctx, hostname, uuid.UUID(id))
} else { } else {
err = client.NewClient().DeleteAccountByName(ctx, hostname, params.AccountID) err = client.NewClient().DeleteAccountByName(ctx, hostname, params.AccountID)
} }
@@ -299,9 +299,9 @@ type ListAccountsParams struct {
} }
type Userinfo struct { type Userinfo struct {
Username string `yaml:"username,omitempty"` Username string `yaml:"username,omitempty"`
AccountID auxuuid.UUID `yaml:"accountId,omitempty"` AccountID uuid.UUID `yaml:"accountId,omitempty"`
Rights map[auxuuid.UUID]string `yaml:"rights,omitempty"` Rights map[uuid.UUID]terms.Right `yaml:"rights,omitempty"`
} }
type ListAccountsResult struct { type ListAccountsResult struct {
@@ -350,7 +350,7 @@ func (util *AccountUtil) listAccounts(common *CommonAccountParams, params *ListA
userinfo := Userinfo{ userinfo := Userinfo{
Username: account.Username, Username: account.Username,
AccountID: account.ID, AccountID: account.ID,
Rights: make(map[auxuuid.UUID]string, 0), Rights: make(map[uuid.UUID]terms.Right, 0),
} }
for _, grant := range account.Grants { for _, grant := range account.Grants {
userinfo.Rights[grant.ID] = grant.Right userinfo.Rights[grant.ID] = grant.Right
+13 -12
View File
@@ -18,9 +18,10 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"mstore/pkg/auxuuid"
"mstore/pkg/client" "mstore/pkg/client"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms"
"mstore/pkg/uuid"
) )
func (util *GrantUtil) CreateGrantCmds() *cobra.Command { func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
@@ -116,7 +117,7 @@ type CreateGrantParams struct {
Pattern string Pattern string
} }
type CreateGrantResult struct { type CreateGrantResult struct {
GrantID auxuuid.UUID `yaml:"grantId"` GrantID uuid.UUID `yaml:"grantId"`
} }
func (util *GrantUtil) CreateGrant(cmd *cobra.Command, args []string) { func (util *GrantUtil) CreateGrant(cmd *cobra.Command, args []string) {
@@ -139,11 +140,11 @@ func (util *GrantUtil) createGrant(common *CommonGrantParams, params *CreateGran
ctx, _ := context.WithTimeout(context.Background(), timeout) ctx, _ := context.WithTimeout(context.Background(), timeout)
re := regexp.MustCompile(uuidRegex) re := regexp.MustCompile(uuidRegex)
id := strings.ToLower(params.AccountID) id := strings.ToLower(params.AccountID)
var operRes auxuuid.UUID var operRes uuid.UUID
if re.MatchString(id) { if re.MatchString(id) {
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, auxuuid.UUID(id), params.Right, params.Pattern) operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, uuid.UUID(id), terms.Right(params.Right), params.Pattern)
} else { } else {
operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, params.Right, params.Pattern) operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, terms.Right(params.Right), params.Pattern)
} }
if err != nil { if err != nil {
return res, err return res, err
@@ -177,7 +178,7 @@ func (util *GrantUtil) updateGrant(common *CommonGrantParams, params *UpdateGran
timeout := time.Duration(common.Timeout) * time.Second timeout := time.Duration(common.Timeout) * time.Second
ctx, _ := context.WithTimeout(context.Background(), timeout) ctx, _ := context.WithTimeout(context.Background(), timeout)
id := strings.ToLower(params.GrantID) id := strings.ToLower(params.GrantID)
err = client.NewClient().UpdateGrant(ctx, hostname, auxuuid.UUID(id), params.Pattern) err = client.NewClient().UpdateGrant(ctx, hostname, uuid.UUID(id), params.Pattern)
if err != nil { if err != nil {
return res, err return res, err
} }
@@ -213,7 +214,7 @@ func (util *GrantUtil) getGrant(common *CommonGrantParams, params *GetGrantParam
opRes := &descr.Grant{} opRes := &descr.Grant{}
id := strings.ToLower(params.GrantID) id := strings.ToLower(params.GrantID)
opRes, err = client.NewClient().GetGrant(ctx, hostname, auxuuid.UUID(id)) opRes, err = client.NewClient().GetGrant(ctx, hostname, uuid.UUID(id))
if err != nil { if err != nil {
return res, err return res, err
} }
@@ -244,7 +245,7 @@ func (util *GrantUtil) deleteGrant(common *CommonGrantParams, params *DeleteGran
timeout := time.Duration(common.Timeout) * time.Second timeout := time.Duration(common.Timeout) * time.Second
ctx, _ := context.WithTimeout(context.Background(), timeout) ctx, _ := context.WithTimeout(context.Background(), timeout)
id := strings.ToLower(params.GrantID) id := strings.ToLower(params.GrantID)
err = client.NewClient().DeleteGrant(ctx, hostname, auxuuid.UUID(id)) err = client.NewClient().DeleteGrant(ctx, hostname, uuid.UUID(id))
if err != nil { if err != nil {
return res, err return res, err
} }
@@ -258,8 +259,8 @@ type ListGrantsParams struct {
} }
type ListGrantsResult struct { type ListGrantsResult struct {
Grants []descr.Grant `yaml:"grants,omitempty"` Grants []descr.Grant `yaml:"grants,omitempty"`
Rights map[auxuuid.UUID]string `yaml:"rights,omitempty"` Rights map[uuid.UUID]terms.Right `yaml:"rights,omitempty"`
} }
func (util *GrantUtil) ListGrants(cmd *cobra.Command, args []string) { func (util *GrantUtil) ListGrants(cmd *cobra.Command, args []string) {
@@ -281,7 +282,7 @@ func (util *GrantUtil) listGrants(common *CommonGrantParams, params *ListGrantsP
re := regexp.MustCompile(uuidRegex) re := regexp.MustCompile(uuidRegex)
id := strings.ToLower(params.AccountID) id := strings.ToLower(params.AccountID)
if re.MatchString(id) { if re.MatchString(id) {
grants, err = client.NewClient().ListGrantsByAccountID(ctx, hostname, auxuuid.UUID(id)) grants, err = client.NewClient().ListGrantsByAccountID(ctx, hostname, uuid.UUID(id))
} else { } else {
grants, err = client.NewClient().ListGrantsByUsername(ctx, hostname, params.AccountID) grants, err = client.NewClient().ListGrantsByUsername(ctx, hostname, params.AccountID)
} }
@@ -291,7 +292,7 @@ func (util *GrantUtil) listGrants(common *CommonGrantParams, params *ListGrantsP
if params.Detail { if params.Detail {
res.Grants = grants res.Grants = grants
} else { } else {
res.Rights = make(map[auxuuid.UUID]string, 0) res.Rights = make(map[uuid.UUID]terms.Right, 0)
for _, item := range grants { for _, item := range grants {
res.Rights[item.ID] = item.Right res.Rights[item.ID] = item.Right
} }
-22
View File
@@ -1,22 +0,0 @@
/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*
* This work is published and licensed under a Creative Commons
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
*
* Distribution of this work is permitted, but commercial use and
* modifications are strictly prohibited.
*/
package auxuuid
import (
"github.com/google/uuid"
)
type UUID string
const ZeroUUID = "00000000-0000-0000-0000-000000000000"
func NewUUID() UUID {
return UUID(uuid.New().String())
}
+6 -6
View File
@@ -16,13 +16,13 @@ import (
"mstore/app/handler" "mstore/app/handler"
"mstore/app/operator" "mstore/app/operator"
"mstore/pkg/auxuuid"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/uuid"
) )
func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, password string) (auxuuid.UUID, error) { func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, password string) (uuid.UUID, error) {
var err error var err error
var res auxuuid.UUID var res uuid.UUID
apiuri, err := setApiPath(hosturi, "/v3/api/account/create") apiuri, err := setApiPath(hosturi, "/v3/api/account/create")
if err != nil { if err != nil {
@@ -54,7 +54,7 @@ func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, passwor
return res, err return res, err
} }
func (cli *Client) GetAccountByID(ctx context.Context, hosturi string, id auxuuid.UUID) (*descr.AccountShort, error) { func (cli *Client) GetAccountByID(ctx context.Context, hosturi string, id uuid.UUID) (*descr.AccountShort, error) {
var err error var err error
res := &descr.AccountShort{} res := &descr.AccountShort{}
@@ -121,7 +121,7 @@ func (cli *Client) GetAccountByName(ctx context.Context, hosturi, username strin
return res, err return res, err
} }
func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, id auxuuid.UUID, newUsername, newPassword string) error { func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, id uuid.UUID, newUsername, newPassword string) error {
var err error var err error
apipath, err := setApiPath(hosturi, "/v3/api/account/update") apipath, err := setApiPath(hosturi, "/v3/api/account/update")
@@ -215,7 +215,7 @@ func (cli *Client) DeleteAccountByName(ctx context.Context, hosturi, username st
return err return err
} }
func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi string, id auxuuid.UUID) error { func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi string, id uuid.UUID) error {
var err error var err error
apipath, err := setApiPath(hosturi, "/v3/api/account/delete") apipath, err := setApiPath(hosturi, "/v3/api/account/delete")
+10 -9
View File
@@ -16,13 +16,14 @@ import (
"mstore/app/handler" "mstore/app/handler"
"mstore/app/operator" "mstore/app/operator"
"mstore/pkg/auxuuid"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms"
"mstore/pkg/uuid"
) )
func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID auxuuid.UUID, right, pattern string) (auxuuid.UUID, error) { func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID uuid.UUID, right terms.Right, pattern string) (uuid.UUID, error) {
var err error var err error
var res auxuuid.UUID var res uuid.UUID
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create") apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
if err != nil { if err != nil {
@@ -55,9 +56,9 @@ func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, a
return res, err return res, err
} }
func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username, right, pattern string) (auxuuid.UUID, error) { func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username string, right terms.Right, pattern string) (uuid.UUID, error) {
var err error var err error
var res auxuuid.UUID var res uuid.UUID
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create") apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
if err != nil { if err != nil {
@@ -90,7 +91,7 @@ func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username,
return res, err return res, err
} }
func (cli *Client) GetGrant(ctx context.Context, hosturi string, id auxuuid.UUID) (*descr.Grant, error) { func (cli *Client) GetGrant(ctx context.Context, hosturi string, id uuid.UUID) (*descr.Grant, error) {
var err error var err error
res := &descr.Grant{} res := &descr.Grant{}
@@ -123,7 +124,7 @@ func (cli *Client) GetGrant(ctx context.Context, hosturi string, id auxuuid.UUID
return res, err return res, err
} }
func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID auxuuid.UUID, newPattern string) error { func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID uuid.UUID, newPattern string) error {
var err error var err error
apipath, err := setApiPath(hosturi, "/v3/api/grant/update") apipath, err := setApiPath(hosturi, "/v3/api/grant/update")
@@ -154,7 +155,7 @@ func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID auxu
return err return err
} }
func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID auxuuid.UUID) error { func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID uuid.UUID) error {
var err error var err error
apipath, err := setApiPath(hosturi, "/v3/api/grant/delete") apipath, err := setApiPath(hosturi, "/v3/api/grant/delete")
@@ -185,7 +186,7 @@ func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID auxu
return err return err
} }
func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi string, accountID auxuuid.UUID) ([]descr.Grant, error) { func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi string, accountID uuid.UUID) ([]descr.Grant, error) {
var err error var err error
res := make([]descr.Grant, 0) res := make([]descr.Grant, 0)
+17 -17
View File
@@ -10,27 +10,27 @@
package descr package descr
import ( import (
"mstore/pkg/auxuuid" "mstore/pkg/uuid"
) )
type Account struct { type Account struct {
ID auxuuid.UUID `json:"id" db:"id"` ID uuid.UUID `json:"id" db:"id"`
Username string `json:"username" db:"username"` Username string `json:"username" db:"username"`
Passhash string `json:"passhash" db:"passhash"` Passhash string `json:"passhash" db:"passhash"`
Disabled bool `json:"disabled" db:"disabled"` Disabled bool `json:"disabled" db:"disabled"`
CreatedAt string `json:"createdAt" db:"created_at"` CreatedAt string `json:"createdAt" db:"created_at"`
UpdatedAt string `json:"updatedAt" db:"updated_at"` UpdatedAt string `json:"updatedAt" db:"updated_at"`
CreatedBy auxuuid.UUID `json:"createdBy" db:"created_by"` CreatedBy uuid.UUID `json:"createdBy" db:"created_by"`
UpdatedBy auxuuid.UUID `json:"updatedBy" db:"updated_by"` UpdatedBy uuid.UUID `json:"updatedBy" db:"updated_by"`
} }
type AccountShort struct { type AccountShort struct {
ID auxuuid.UUID `json:"id"` ID uuid.UUID `json:"id"`
Username string `json:"username"` Username string `json:"username"`
Disabled bool `json:"disabled"` Disabled bool `json:"disabled"`
CreatedAt string `json:"createdAt"` CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"` UpdatedAt string `json:"updatedAt"`
CreatedBy auxuuid.UUID `json:"createdBy"` CreatedBy uuid.UUID `json:"createdBy"`
UpdatedBy auxuuid.UUID `json:"updatedBy"` UpdatedBy uuid.UUID `json:"updatedBy"`
Grants []Grant `json:"grants"` Grants []Grant `json:"grants"`
} }
+11 -11
View File
@@ -10,18 +10,18 @@
package descr package descr
import ( import (
"mstore/pkg/auxuuid" "mstore/pkg/uuid"
) )
type Blob struct { type Blob struct {
ID auxuuid.UUID `db:"id" json:"id"` ID uuid.UUID `db:"id" json:"id"`
Name string `db:"name" json:"name"` Name string `db:"name" json:"name"`
Reference string `db:"reference" json:"reference"` Reference string `db:"reference" json:"reference"`
MediaType string `db:"mediaType" json:"mediaType"` MediaType string `db:"mediaType" json:"mediaType"`
Digest string `db:"digest" json:"digest"` Digest string `db:"digest" json:"digest"`
Size int64 `db:"size" json:"size"` Size int64 `db:"size" json:"size"`
CreatedAt string `db:"created_at" json:"createdAt"` CreatedAt string `db:"created_at" json:"createdAt"`
UpdatedAt string `db:"updated_at" json:"updatedAt"` UpdatedAt string `db:"updated_at" json:"updatedAt"`
CreatedBy auxuuid.UUID `db:"created_by" json:"createdBy,omitempty"` CreatedBy uuid.UUID `db:"created_by" json:"createdBy,omitempty"`
UpdatedBy auxuuid.UUID `db:"updated_by" json:"updatedBy,omitempty"` UpdatedBy uuid.UUID `db:"updated_by" json:"updatedBy,omitempty"`
} }
+11 -11
View File
@@ -10,18 +10,18 @@
package descr package descr
import ( import (
"mstore/pkg/auxuuid" "mstore/pkg/uuid"
) )
type File struct { type File struct {
ID auxuuid.UUID `db:"id" json:"id,omitempty" yaml:"id,omitempty"` ID uuid.UUID `db:"id" json:"id,omitempty" yaml:"id,omitempty"`
Collection string `db:"collection" json:"collection,omitempty" yaml:"collection,omitempty"` Collection string `db:"collection" json:"collection,omitempty" yaml:"collection,omitempty"`
Name string `db:"name" json:"name,omitempty" yaml:"name,omitempty"` Name string `db:"name" json:"name,omitempty" yaml:"name,omitempty"`
Type string `db:"type" json:"type,omitempty" yaml:"type,omitempty"` Type string `db:"type" json:"type,omitempty" yaml:"type,omitempty"`
Checksum string `db:"checksum" json:"checksum,omitempty" yaml:"checksum,omitempty"` Checksum string `db:"checksum" json:"checksum,omitempty" yaml:"checksum,omitempty"`
Size int64 `db:"size" json:"size,omitempty" yaml:"size,omitempty"` Size int64 `db:"size" json:"size,omitempty" yaml:"size,omitempty"`
CreatedAt string `db:"created_at" json:"createdAt,omitempty" yaml:"createdAt,omitempty"` CreatedAt string `db:"created_at" json:"createdAt,omitempty" yaml:"createdAt,omitempty"`
UpdatedAt string `db:"updated_at" json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"` UpdatedAt string `db:"updated_at" json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"`
CreatedBy auxuuid.UUID `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"` CreatedBy uuid.UUID `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"`
UpdatedBy auxuuid.UUID `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"` UpdatedBy uuid.UUID `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"`
} }
+10 -9
View File
@@ -11,16 +11,17 @@
package descr package descr
import ( import (
"mstore/pkg/auxuuid" "mstore/pkg/terms"
"mstore/pkg/uuid"
) )
type Grant struct { type Grant struct {
ID auxuuid.UUID `json:"id" db:"id"` ID uuid.UUID `json:"id" db:"id"`
AccountID auxuuid.UUID `json:"accountID" db:"account_id"` AccountID uuid.UUID `json:"accountID" db:"account_id"`
Right string `json:"right" db:"right"` Right terms.Right `json:"right" db:"right"`
Pattern string `json:"pattern" db:"pattern"` Pattern string `json:"pattern" db:"pattern"`
CreatedAt string `json:"createdAt" db:"created_at"` CreatedAt string `json:"createdAt" db:"created_at"`
UpdatedAt string `json:"updatedAt" db:"updated_at"` UpdatedAt string `json:"updatedAt" db:"updated_at"`
CreatedBy auxuuid.UUID `json:"createdBy" db:"created_by"` CreatedBy uuid.UUID `json:"createdBy" db:"created_by"`
UpdatedBy auxuuid.UUID `json:"updatedBy" db:"updated_by"` UpdatedBy uuid.UUID `json:"updatedBy" db:"updated_by"`
} }
+11 -11
View File
@@ -10,20 +10,20 @@
package descr package descr
import ( import (
"mstore/pkg/auxuuid" "mstore/pkg/uuid"
) )
type Manifest struct { type Manifest struct {
ID auxuuid.UUID `db:"id" json:"id"` ID uuid.UUID `db:"id" json:"id"`
Name string `db:"name" json:"name"` Name string `db:"name" json:"name"`
Reference string `db:"reference" json:"reference"` Reference string `db:"reference" json:"reference"`
ContentType string `db:"contentType" json:"contentType"` ContentType string `db:"contentType" json:"contentType"`
Payload string `db:"payload" json:"-"` Payload string `db:"payload" json:"-"`
Digest string `db:"digest" json:"digest"` Digest string `db:"digest" json:"digest"`
CreatedAt string `db:"created_at" json:"createdAt"` CreatedAt string `db:"created_at" json:"createdAt"`
UpdatedAt string `db:"updated_at" json:"updatedAt"` UpdatedAt string `db:"updated_at" json:"updatedAt"`
CreatedBy auxuuid.UUID `db:"created_by" json:"createdBy,omitempty"` CreatedBy uuid.UUID `db:"created_by" json:"createdBy,omitempty"`
UpdatedBy auxuuid.UUID `db:"updated_by" json:"updatedBy,omitempty"` UpdatedBy uuid.UUID `db:"updated_by" json:"updatedBy,omitempty"`
} }
type Tags struct { type Tags struct {
+15 -13
View File
@@ -11,7 +11,7 @@
package terms package terms
import ( import (
"mstore/pkg/auxuuid" "mstore/pkg/uuid"
) )
type PathUsage string type PathUsage string
@@ -23,20 +23,22 @@ const (
) )
const ( const (
AnonimousUsername string = "anonymous" AnonimousUsername string = "anonymous"
AnonymousID auxuuid.UUID = "10000000-0000-0000-0000-000000000001" AnonymousID uuid.UUID = "10000000-0000-0000-0000-000000000001"
ServerUsername string = "server" ServerUsername string = "server"
ServerID auxuuid.UUID = "10000000-0000-0000-0000-000000000002" ServerID uuid.UUID = "10000000-0000-0000-0000-000000000002"
InitUsername string = "mstore" InitUsername string = "mstore"
InitID auxuuid.UUID = "10000000-0000-0000-0000-000000000005" InitID uuid.UUID = "10000000-0000-0000-0000-000000000005"
) )
type Right string
const ( const (
// Accounts, grants // Accounts, grants
RightReadAccounts = "readAccounts" // GetAccount, ListAccounts RightReadAccounts Right = "readAccounts" // GetAccount, ListAccounts
RightWriteAccounts = "writeAccounts" // CreateAccount, UpdateAccount, DeleteAccount RightWriteAccounts Right = "writeAccounts" // CreateAccount, UpdateAccount, DeleteAccount
RightWriteFiles = "writeFiles" // FileInfo, GetFile, ListFiles RightWriteFiles Right = "writeFiles" // FileInfo, GetFile, ListFiles
RightReadFiles = "readFiles" // PutFile, DeleteFile RightReadFiles Right = "readFiles" // PutFile, DeleteFile
RightReadImages = "readImages" // ManifestInfo, GetManifest, BlobInfo, GetBlob RightReadImages Right = "readImages" // ManifestInfo, GetManifest, BlobInfo, GetBlob
RightWriteImages = "writeImages" // other opearion RightWriteImages Right = "writeImages" // other opearion
) )
+3 -3
View File
@@ -17,9 +17,9 @@ import (
"time" "time"
"mstore/app/server" "mstore/app/server"
"mstore/pkg/auxuuid"
"mstore/pkg/client" "mstore/pkg/client"
"mstore/pkg/terms" "mstore/pkg/terms"
"mstore/pkg/uuid"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -81,7 +81,7 @@ func TestAccountLife(t *testing.T) {
username := "testuser" username := "testuser"
password := "testpass" password := "testpass"
var accountID auxuuid.UUID var accountID uuid.UUID
{ {
// CreateAccount // CreateAccount
fmt.Printf("=== CreateAccount ===\n") fmt.Printf("=== CreateAccount ===\n")
@@ -92,7 +92,7 @@ func TestAccountLife(t *testing.T) {
accountID, err = cli.CreateAccount(ctx, srvaddr, username, password) accountID, err = cli.CreateAccount(ctx, srvaddr, username, password)
require.NoError(t, err) require.NoError(t, err)
} }
var grantID auxuuid.UUID var grantID uuid.UUID
{ {
// CreateGrant // CreateGrant
fmt.Printf("=== CreateGrant ===\n") fmt.Printf("=== CreateGrant ===\n")