working commit
This commit is contained in:
+14
-14
@@ -7,7 +7,7 @@ import (
|
||||
"mstore/pkg/auxpwd"
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/uuid"
|
||||
"mstore/pkg/auxid"
|
||||
)
|
||||
|
||||
type CreateAccountParams struct {
|
||||
@@ -15,10 +15,10 @@ type CreateAccountParams struct {
|
||||
Password string `json:"password"`
|
||||
}
|
||||
type CreateAccountResult struct {
|
||||
AccountID uuid.UUID `json:"accountId"`
|
||||
AccountID uint64 `json:"accountId"`
|
||||
}
|
||||
|
||||
func (oper *Operator) CreateAccount(ctx context.Context, operatorID uuid.UUID, params *CreateAccountParams) (*CreateAccountResult, error) {
|
||||
func (oper *Operator) CreateAccount(ctx context.Context, operatorID uint64, params *CreateAccountParams) (*CreateAccountResult, error) {
|
||||
var err error
|
||||
res := &CreateAccountResult{}
|
||||
|
||||
@@ -43,7 +43,7 @@ func (oper *Operator) CreateAccount(ctx context.Context, operatorID uuid.UUID, p
|
||||
now := auxtool.TimeNow()
|
||||
passhash := auxpwd.MakeSHA256Hash([]byte(params.Password))
|
||||
accountDescr := &descr.Account{
|
||||
ID: uuid.NewUUID(),
|
||||
ID: auxid.NewID(),
|
||||
Username: params.Username,
|
||||
Passhash: passhash,
|
||||
Disabled: false,
|
||||
@@ -63,17 +63,17 @@ func (oper *Operator) CreateAccount(ctx context.Context, operatorID uuid.UUID, p
|
||||
// GetAccount
|
||||
type GetAccountParams struct {
|
||||
Username string `json:"username"`
|
||||
AccountID uuid.UUID `json:"accountId"`
|
||||
AccountID uint64 `json:"accountId"`
|
||||
}
|
||||
type GetAccountResult struct {
|
||||
Account *descr.AccountShort `json:"account"`
|
||||
}
|
||||
|
||||
func (oper *Operator) GetAccount(ctx context.Context, operatorID uuid.UUID, params *GetAccountParams) (*GetAccountResult, error) {
|
||||
func (oper *Operator) GetAccount(ctx context.Context, operatorID uint64, params *GetAccountParams) (*GetAccountResult, error) {
|
||||
var err error
|
||||
res := &GetAccountResult{}
|
||||
|
||||
if params.Username == "" && params.AccountID == "" {
|
||||
if params.Username == "" && params.AccountID == 0 {
|
||||
err := fmt.Errorf("Empty username and accountId parameter")
|
||||
return res, err
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func (oper *Operator) GetAccount(ctx context.Context, operatorID uuid.UUID, para
|
||||
var accountDescr *descr.Account
|
||||
var accountExists bool
|
||||
switch {
|
||||
case params.AccountID != "":
|
||||
case params.AccountID != 0:
|
||||
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.AccountID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -129,24 +129,24 @@ func (oper *Operator) GetAccount(ctx context.Context, operatorID uuid.UUID, para
|
||||
|
||||
type UpdateAccountParams struct {
|
||||
Username string `json:"username"`
|
||||
AccountID uuid.UUID `json:"accountId"`
|
||||
AccountID uint64 `json:"accountId"`
|
||||
NewUsername string `json:"newUsername"`
|
||||
NewPassword string `json:"newPassword"`
|
||||
Disabled bool `json:"disabled"`
|
||||
}
|
||||
type UpdateAccountResult struct{}
|
||||
|
||||
func (oper *Operator) UpdateAccount(ctx context.Context, operatorID uuid.UUID, params *UpdateAccountParams) (*UpdateAccountResult, error) {
|
||||
func (oper *Operator) UpdateAccount(ctx context.Context, operatorID uint64, params *UpdateAccountParams) (*UpdateAccountResult, error) {
|
||||
var err error
|
||||
res := &UpdateAccountResult{}
|
||||
if params.Username == "" && params.AccountID == "" {
|
||||
if params.Username == "" && params.AccountID == 0 {
|
||||
err := fmt.Errorf("Empty username and accountId parameter")
|
||||
return res, err
|
||||
}
|
||||
var accountDescr *descr.Account
|
||||
var accountExists bool
|
||||
switch {
|
||||
case params.AccountID != "":
|
||||
case params.AccountID != 0:
|
||||
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.AccountID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -196,11 +196,11 @@ func (oper *Operator) UpdateAccount(ctx context.Context, operatorID uuid.UUID, p
|
||||
|
||||
type DeleteAccountParams struct {
|
||||
Username string `json:"username"`
|
||||
AccountID uuid.UUID `json:"accountId"`
|
||||
AccountID uint64 `json:"accountId"`
|
||||
}
|
||||
type DeleteAccountResult struct{}
|
||||
|
||||
func (oper *Operator) DeleteAccount(ctx context.Context, operatorID uuid.UUID, params *DeleteAccountParams) (*DeleteAccountResult, error) {
|
||||
func (oper *Operator) DeleteAccount(ctx context.Context, operatorID uint64, params *DeleteAccountParams) (*DeleteAccountResult, error) {
|
||||
var err error
|
||||
res := &DeleteAccountResult{}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"mstore/pkg/uuid"
|
||||
"mstore/pkg/auxid"
|
||||
)
|
||||
|
||||
type BlobExistsParams struct {
|
||||
@@ -73,7 +73,7 @@ type PostUploadParams struct {
|
||||
From string
|
||||
}
|
||||
type PostUploadResult struct {
|
||||
DockerUploadUUID uuid.UUID
|
||||
DockerUploadUUID uint64
|
||||
Location string
|
||||
ContentLength string
|
||||
}
|
||||
|
||||
+12
-12
@@ -24,7 +24,7 @@ import (
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
"mstore/pkg/auxid"
|
||||
)
|
||||
|
||||
// FileInfo
|
||||
@@ -41,9 +41,9 @@ type FileInfoResult struct {
|
||||
ContentDigest string
|
||||
|
||||
ContentCreatedAt string
|
||||
ContentCreatedBy uuid.UUID
|
||||
ContentCreatedBy uint64
|
||||
ContentUpdatedAt string
|
||||
ContentUpdatedBy uuid.UUID
|
||||
ContentUpdatedBy uint64
|
||||
}
|
||||
|
||||
func cleanFilepath(filename string) (string, error) {
|
||||
@@ -51,7 +51,7 @@ func cleanFilepath(filename string) (string, error) {
|
||||
return filepath.Clean(filename), nil
|
||||
}
|
||||
|
||||
func (oper *Operator) FileInfo(ctx context.Context, operatorID uuid.UUID, param *FileInfoParams) (int, *FileInfoResult, error) {
|
||||
func (oper *Operator) FileInfo(ctx context.Context, operatorID uint64, param *FileInfoParams) (int, *FileInfoResult, error) {
|
||||
var err error
|
||||
code := http.StatusOK
|
||||
res := &FileInfoResult{}
|
||||
@@ -101,7 +101,7 @@ type PutFileResult struct{}
|
||||
const defaultContentType = "application/octet-stream"
|
||||
|
||||
// TODO: checking catalog and file names conflict
|
||||
func (oper *Operator) PutFile(ctx context.Context, operatorID uuid.UUID, param *PutFileParams) (int, *PutFileResult, error) {
|
||||
func (oper *Operator) PutFile(ctx context.Context, operatorID uint64, param *PutFileParams) (int, *PutFileResult, error) {
|
||||
var err error
|
||||
res := &PutFileResult{}
|
||||
|
||||
@@ -193,12 +193,12 @@ type GetFileResult struct {
|
||||
Source io.ReadCloser
|
||||
|
||||
ContentCreatedAt string
|
||||
ContentCreatedBy uuid.UUID
|
||||
ContentCreatedBy uint64
|
||||
ContentUpdatedAt string
|
||||
ContentUpdatedBy uuid.UUID
|
||||
ContentUpdatedBy uint64
|
||||
}
|
||||
|
||||
func (oper *Operator) GetFile(ctx context.Context, operatorID uuid.UUID, param *GetFileParams) (int, *GetFileResult, error) {
|
||||
func (oper *Operator) GetFile(ctx context.Context, operatorID uint64, param *GetFileParams) (int, *GetFileResult, error) {
|
||||
var err error
|
||||
res := &GetFileResult{}
|
||||
|
||||
@@ -247,7 +247,7 @@ type DeleteFileParams struct {
|
||||
}
|
||||
type DeleteFileResult struct{}
|
||||
|
||||
func (oper *Operator) DeleteFile(ctx context.Context, operatorID uuid.UUID, param *DeleteFileParams) (int, *DeleteFileResult, error) {
|
||||
func (oper *Operator) DeleteFile(ctx context.Context, operatorID uint64, param *DeleteFileParams) (int, *DeleteFileResult, error) {
|
||||
var err error
|
||||
res := &DeleteFileResult{}
|
||||
code := http.StatusOK
|
||||
@@ -294,7 +294,7 @@ type ListFilesResult struct {
|
||||
Files []descr.File `json:"files,omitempty"`
|
||||
}
|
||||
|
||||
func (oper *Operator) ListFiles(ctx context.Context, operatorID uuid.UUID, params *ListFilesParams) (int, *ListFilesResult, error) {
|
||||
func (oper *Operator) ListFiles(ctx context.Context, operatorID uint64, params *ListFilesParams) (int, *ListFilesResult, error) {
|
||||
var err error
|
||||
res := &ListFilesResult{
|
||||
Files: make([]descr.File, 0),
|
||||
@@ -406,7 +406,7 @@ type ListCollectionsResult struct {
|
||||
Collections []string `json:"collection,omitempty"`
|
||||
}
|
||||
|
||||
func (oper *Operator) ListCollections(ctx context.Context, operatorID uuid.UUID, param *ListCollectionsParams) (int, *ListCollectionsResult, error) {
|
||||
func (oper *Operator) ListCollections(ctx context.Context, operatorID uint64, param *ListCollectionsParams) (int, *ListCollectionsResult, error) {
|
||||
var err error
|
||||
res := &ListCollectionsResult{
|
||||
Collections: make([]string, 0),
|
||||
@@ -539,7 +539,7 @@ type DeleteColletionResult struct {
|
||||
Files []descr.File `json:"files,omitempty"`
|
||||
}
|
||||
|
||||
func (oper *Operator) DeleteColletion(ctx context.Context, operatorID uuid.UUID, param *DeleteColletionParams) (int, *DeleteColletionResult, error) {
|
||||
func (oper *Operator) DeleteColletion(ctx context.Context, operatorID uint64, param *DeleteColletionParams) (int, *DeleteColletionResult, error) {
|
||||
var err error
|
||||
res := &DeleteColletionResult{
|
||||
Files: make([]descr.File, 0),
|
||||
|
||||
+12
-12
@@ -8,21 +8,21 @@ import (
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
"mstore/pkg/auxid"
|
||||
)
|
||||
|
||||
// CreateGrant
|
||||
type CreateGrantParams struct {
|
||||
AccountID uuid.UUID `json:"accountID"`
|
||||
AccountID uint64 `json:"accountID"`
|
||||
Username string `json:"username"`
|
||||
Right term.Right `json:"operation"`
|
||||
Pattern string `json:"pattern"`
|
||||
}
|
||||
type CreateGrantResult struct {
|
||||
GrantID uuid.UUID `json:"grantId"`
|
||||
GrantID uint64 `json:"grantId"`
|
||||
}
|
||||
|
||||
func (oper *Operator) CreateGrant(ctx context.Context, operatorID uuid.UUID, params *CreateGrantParams) (*CreateGrantResult, error) {
|
||||
func (oper *Operator) CreateGrant(ctx context.Context, operatorID uint64, params *CreateGrantParams) (*CreateGrantResult, error) {
|
||||
var err error
|
||||
res := &CreateGrantResult{}
|
||||
|
||||
@@ -100,12 +100,12 @@ func (oper *Operator) CreateGrant(ctx context.Context, operatorID uuid.UUID, par
|
||||
|
||||
// UpdateGrant
|
||||
type UpdateGrantParams struct {
|
||||
GrantID uuid.UUID
|
||||
GrantID uint64
|
||||
NewPattern string
|
||||
}
|
||||
type UpdateGrantResult struct{}
|
||||
|
||||
func (oper *Operator) UpdateGrant(ctx context.Context, operatorID uuid.UUID, params *UpdateGrantParams) (*UpdateGrantResult, error) {
|
||||
func (oper *Operator) UpdateGrant(ctx context.Context, operatorID uint64, params *UpdateGrantParams) (*UpdateGrantResult, error) {
|
||||
var err error
|
||||
res := &UpdateGrantResult{}
|
||||
|
||||
@@ -143,11 +143,11 @@ func (oper *Operator) UpdateGrant(ctx context.Context, operatorID uuid.UUID, par
|
||||
|
||||
// DeleteGrant
|
||||
type DeleteGrantParams struct {
|
||||
GrantID uuid.UUID `json:"grantId"`
|
||||
GrantID uint64 `json:"grantId"`
|
||||
}
|
||||
type DeleteGrantResult struct{}
|
||||
|
||||
func (oper *Operator) DeleteGrant(ctx context.Context, operatorID uuid.UUID, params *DeleteGrantParams) (*DeleteGrantResult, error) {
|
||||
func (oper *Operator) DeleteGrant(ctx context.Context, operatorID uint64, params *DeleteGrantParams) (*DeleteGrantResult, error) {
|
||||
var err error
|
||||
res := &DeleteGrantResult{}
|
||||
|
||||
@@ -177,13 +177,13 @@ func (oper *Operator) DeleteGrant(ctx context.Context, operatorID uuid.UUID, par
|
||||
// ListGrants
|
||||
type ListGrantsParams struct {
|
||||
Username string
|
||||
AccountID uuid.UUID
|
||||
AccountID uint64
|
||||
}
|
||||
type ListGrantsResult struct {
|
||||
Grants []descr.Grant `json:"grants"`
|
||||
}
|
||||
|
||||
func (oper *Operator) ListGrants(ctx context.Context, operatorID uuid.UUID, params *ListGrantsParams) (*ListGrantsResult, error) {
|
||||
func (oper *Operator) ListGrants(ctx context.Context, operatorID uint64, params *ListGrantsParams) (*ListGrantsResult, error) {
|
||||
var err error
|
||||
res := &ListGrantsResult{
|
||||
Grants: make([]descr.Grant, 0),
|
||||
@@ -224,13 +224,13 @@ func (oper *Operator) ListGrants(ctx context.Context, operatorID uuid.UUID, para
|
||||
|
||||
// Get Grants
|
||||
type GetGrantParams struct {
|
||||
GrantID uuid.UUID `json:"grantId"`
|
||||
GrantID uint64 `json:"grantId"`
|
||||
}
|
||||
type GetGrantResult struct {
|
||||
Grant *descr.Grant `json:"grant"`
|
||||
}
|
||||
|
||||
func (oper *Operator) GetGrant(ctx context.Context, operatorID uuid.UUID, params *GetGrantParams) (*GetGrantResult, error) {
|
||||
func (oper *Operator) GetGrant(ctx context.Context, operatorID uint64, params *GetGrantParams) (*GetGrantResult, error) {
|
||||
var err error
|
||||
res := &GetGrantResult{}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ package operator
|
||||
import (
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/uuid"
|
||||
"mstore/pkg/auxid"
|
||||
|
||||
ocidigest "github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
|
||||
Reference in New Issue
Block a user