working commit
This commit is contained in:
+20
-20
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
"mstore/pkg/auxpwd"
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/auxid"
|
||||
)
|
||||
|
||||
type CreateAccountParams struct {
|
||||
@@ -15,10 +15,10 @@ type CreateAccountParams struct {
|
||||
Password string `json:"password"`
|
||||
}
|
||||
type CreateAccountResult struct {
|
||||
AccountID uint64 `json:"accountId"`
|
||||
AccountID string `json:"accountId"`
|
||||
}
|
||||
|
||||
func (oper *Operator) CreateAccount(ctx context.Context, operatorID uint64, params *CreateAccountParams) (*CreateAccountResult, error) {
|
||||
func (oper *Operator) CreateAccount(ctx context.Context, operatorID string, params *CreateAccountParams) (*CreateAccountResult, error) {
|
||||
var err error
|
||||
res := &CreateAccountResult{}
|
||||
|
||||
@@ -43,7 +43,7 @@ func (oper *Operator) CreateAccount(ctx context.Context, operatorID uint64, para
|
||||
now := auxtool.TimeNow()
|
||||
passhash := auxpwd.MakeSHA256Hash([]byte(params.Password))
|
||||
accountDescr := &descr.Account{
|
||||
ID: auxid.NewID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
Username: params.Username,
|
||||
Passhash: passhash,
|
||||
Disabled: false,
|
||||
@@ -62,18 +62,18 @@ func (oper *Operator) CreateAccount(ctx context.Context, operatorID uint64, para
|
||||
|
||||
// GetAccount
|
||||
type GetAccountParams struct {
|
||||
Username string `json:"username"`
|
||||
AccountID uint64 `json:"accountId"`
|
||||
Username string `json:"username"`
|
||||
AccountID string `json:"accountId"`
|
||||
}
|
||||
type GetAccountResult struct {
|
||||
Account *descr.AccountShort `json:"account"`
|
||||
}
|
||||
|
||||
func (oper *Operator) GetAccount(ctx context.Context, operatorID uint64, params *GetAccountParams) (*GetAccountResult, error) {
|
||||
func (oper *Operator) GetAccount(ctx context.Context, operatorID string, params *GetAccountParams) (*GetAccountResult, error) {
|
||||
var err error
|
||||
res := &GetAccountResult{}
|
||||
|
||||
if params.Username == "" && params.AccountID == 0 {
|
||||
if params.Username == "" && params.AccountID == "" {
|
||||
err := fmt.Errorf("Empty username and accountId parameter")
|
||||
return res, err
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func (oper *Operator) GetAccount(ctx context.Context, operatorID uint64, params
|
||||
var accountDescr *descr.Account
|
||||
var accountExists bool
|
||||
switch {
|
||||
case params.AccountID != 0:
|
||||
case params.AccountID != "":
|
||||
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.AccountID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -128,25 +128,25 @@ func (oper *Operator) GetAccount(ctx context.Context, operatorID uint64, params
|
||||
}
|
||||
|
||||
type UpdateAccountParams struct {
|
||||
Username string `json:"username"`
|
||||
AccountID uint64 `json:"accountId"`
|
||||
NewUsername string `json:"newUsername"`
|
||||
NewPassword string `json:"newPassword"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Username string `json:"username"`
|
||||
AccountID string `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 uint64, params *UpdateAccountParams) (*UpdateAccountResult, error) {
|
||||
func (oper *Operator) UpdateAccount(ctx context.Context, operatorID string, params *UpdateAccountParams) (*UpdateAccountResult, error) {
|
||||
var err error
|
||||
res := &UpdateAccountResult{}
|
||||
if params.Username == "" && params.AccountID == 0 {
|
||||
if params.Username == "" && params.AccountID == "" {
|
||||
err := fmt.Errorf("Empty username and accountId parameter")
|
||||
return res, err
|
||||
}
|
||||
var accountDescr *descr.Account
|
||||
var accountExists bool
|
||||
switch {
|
||||
case params.AccountID != 0:
|
||||
case params.AccountID != "":
|
||||
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.AccountID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -195,12 +195,12 @@ func (oper *Operator) UpdateAccount(ctx context.Context, operatorID uint64, para
|
||||
}
|
||||
|
||||
type DeleteAccountParams struct {
|
||||
Username string `json:"username"`
|
||||
AccountID uint64 `json:"accountId"`
|
||||
Username string `json:"username"`
|
||||
AccountID string `json:"accountId"`
|
||||
}
|
||||
type DeleteAccountResult struct{}
|
||||
|
||||
func (oper *Operator) DeleteAccount(ctx context.Context, operatorID uint64, params *DeleteAccountParams) (*DeleteAccountResult, error) {
|
||||
func (oper *Operator) DeleteAccount(ctx context.Context, operatorID string, params *DeleteAccountParams) (*DeleteAccountResult, error) {
|
||||
var err error
|
||||
res := &DeleteAccountResult{}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"mstore/pkg/auxid"
|
||||
"mstore/pkg/auxuuid"
|
||||
)
|
||||
|
||||
type BlobExistsParams struct {
|
||||
@@ -30,7 +30,7 @@ type BlobExistsResult struct {
|
||||
//Exists bool
|
||||
}
|
||||
|
||||
func (oper *Operator) BlobExists(ctx context.Context, params *BlobExistsParams) (*BlobExistsResult, int, error) {
|
||||
func (oper *Operator) BlobExists(ctx context.Context, operatorID string, params *BlobExistsParams) (*BlobExistsResult, int, error) {
|
||||
var err error
|
||||
res := &BlobExistsResult{}
|
||||
|
||||
@@ -73,17 +73,17 @@ type PostUploadParams struct {
|
||||
From string
|
||||
}
|
||||
type PostUploadResult struct {
|
||||
DockerUploadUUID uint64
|
||||
DockerUploadUUID string
|
||||
Location string
|
||||
ContentLength string
|
||||
}
|
||||
|
||||
func (oper *Operator) PostUpload(ctx context.Context, params *PostUploadParams) (*PostUploadResult, int, error) {
|
||||
func (oper *Operator) PostUpload(ctx context.Context, operatorID string, params *PostUploadParams) (*PostUploadResult, int, error) {
|
||||
var err error
|
||||
res := &PostUploadResult{}
|
||||
|
||||
if params.Digest == "" {
|
||||
uuid := uuid.NewUUID()
|
||||
uuid := auxuuid.NewUUID()
|
||||
location := fmt.Sprintf("/v2/%s/blobs/uploads/%s", params.Name, uuid)
|
||||
res.DockerUploadUUID = uuid
|
||||
res.Location = location
|
||||
@@ -110,7 +110,7 @@ type PatchUploadResult struct {
|
||||
}
|
||||
|
||||
// TODO: partial uploading by range?
|
||||
func (oper *Operator) PatchUpload(ctx context.Context, params *PatchUploadParams) (*PatchUploadResult, int, error) {
|
||||
func (oper *Operator) PatchUpload(ctx context.Context, operatorID string, params *PatchUploadParams) (*PatchUploadResult, int, error) {
|
||||
var err error
|
||||
res := &PatchUploadResult{}
|
||||
|
||||
@@ -177,7 +177,7 @@ type PutUploadResult struct {
|
||||
Location string
|
||||
}
|
||||
|
||||
func (oper *Operator) PutUpload(ctx context.Context, params *PutUploadParams) (*PutUploadResult, int, error) {
|
||||
func (oper *Operator) PutUpload(ctx context.Context, operatorID string, params *PutUploadParams) (*PutUploadResult, int, error) {
|
||||
var err error
|
||||
res := &PutUploadResult{}
|
||||
|
||||
@@ -234,7 +234,7 @@ type GetBlobResult struct {
|
||||
ReadCloser io.ReadCloser
|
||||
}
|
||||
|
||||
func (oper *Operator) GetBlob(ctx context.Context, params *GetBlobParams) (*GetBlobResult, int, error) {
|
||||
func (oper *Operator) GetBlob(ctx context.Context, operatorID string, params *GetBlobParams) (*GetBlobResult, int, error) {
|
||||
var err error
|
||||
res := &GetBlobResult{}
|
||||
|
||||
@@ -282,7 +282,7 @@ type DeleteBlobResult struct{}
|
||||
// - It also prevents the manifest from being issued, as one
|
||||
// of the layers is missing.
|
||||
|
||||
func (oper *Operator) DeleteBlob(ctx context.Context, params *DeleteBlobParams) (*DeleteBlobResult, int, error) {
|
||||
func (oper *Operator) DeleteBlob(ctx context.Context, operatorID string, params *DeleteBlobParams) (*DeleteBlobResult, int, error) {
|
||||
var err error
|
||||
res := &DeleteBlobResult{}
|
||||
|
||||
|
||||
+17
-17
@@ -22,9 +22,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/auxid"
|
||||
)
|
||||
|
||||
// FileInfo
|
||||
@@ -41,9 +41,9 @@ type FileInfoResult struct {
|
||||
ContentDigest string
|
||||
|
||||
ContentCreatedAt string
|
||||
ContentCreatedBy uint64
|
||||
ContentCreatedBy string
|
||||
ContentUpdatedAt string
|
||||
ContentUpdatedBy uint64
|
||||
ContentUpdatedBy string
|
||||
}
|
||||
|
||||
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 uint64, param *FileInfoParams) (int, *FileInfoResult, error) {
|
||||
func (oper *Operator) FileInfo(ctx context.Context, operatorID string, 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 uint64, param *PutFileParams) (int, *PutFileResult, error) {
|
||||
func (oper *Operator) PutFile(ctx context.Context, operatorID string, param *PutFileParams) (int, *PutFileResult, error) {
|
||||
var err error
|
||||
res := &PutFileResult{}
|
||||
|
||||
@@ -155,7 +155,7 @@ func (oper *Operator) PutFile(ctx context.Context, operatorID uint64, param *Put
|
||||
}
|
||||
} else {
|
||||
fileDescr = &descr.File{
|
||||
ID: uuid.NewUUID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
Name: filename,
|
||||
Collection: collection,
|
||||
Size: size,
|
||||
@@ -193,12 +193,12 @@ type GetFileResult struct {
|
||||
Source io.ReadCloser
|
||||
|
||||
ContentCreatedAt string
|
||||
ContentCreatedBy uint64
|
||||
ContentCreatedBy string
|
||||
ContentUpdatedAt string
|
||||
ContentUpdatedBy uint64
|
||||
ContentUpdatedBy string
|
||||
}
|
||||
|
||||
func (oper *Operator) GetFile(ctx context.Context, operatorID uint64, param *GetFileParams) (int, *GetFileResult, error) {
|
||||
func (oper *Operator) GetFile(ctx context.Context, operatorID string, 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 uint64, param *DeleteFileParams) (int, *DeleteFileResult, error) {
|
||||
func (oper *Operator) DeleteFile(ctx context.Context, operatorID string, param *DeleteFileParams) (int, *DeleteFileResult, error) {
|
||||
var err error
|
||||
res := &DeleteFileResult{}
|
||||
code := http.StatusOK
|
||||
@@ -288,13 +288,13 @@ func (oper *Operator) DeleteFile(ctx context.Context, operatorID uint64, param *
|
||||
// ListFiles
|
||||
type ListFilesParams struct {
|
||||
Filepath string
|
||||
PathAs term.PathUsage `param:"pathAs"`
|
||||
PathAs string `param:"pathAs"`
|
||||
}
|
||||
type ListFilesResult struct {
|
||||
Files []descr.File `json:"files,omitempty"`
|
||||
}
|
||||
|
||||
func (oper *Operator) ListFiles(ctx context.Context, operatorID uint64, params *ListFilesParams) (int, *ListFilesResult, error) {
|
||||
func (oper *Operator) ListFiles(ctx context.Context, operatorID string, params *ListFilesParams) (int, *ListFilesResult, error) {
|
||||
var err error
|
||||
res := &ListFilesResult{
|
||||
Files: make([]descr.File, 0),
|
||||
@@ -400,13 +400,13 @@ func (oper *Operator) listFilesWithRegex(ctx context.Context, regex string) ([]d
|
||||
// ListCollections
|
||||
type ListCollectionsParams struct {
|
||||
Path string
|
||||
PathAS term.PathUsage `param:"pathAs"`
|
||||
PathAS string `param:"pathAs"`
|
||||
}
|
||||
type ListCollectionsResult struct {
|
||||
Collections []string `json:"collection,omitempty"`
|
||||
}
|
||||
|
||||
func (oper *Operator) ListCollections(ctx context.Context, operatorID uint64, param *ListCollectionsParams) (int, *ListCollectionsResult, error) {
|
||||
func (oper *Operator) ListCollections(ctx context.Context, operatorID string, param *ListCollectionsParams) (int, *ListCollectionsResult, error) {
|
||||
var err error
|
||||
res := &ListCollectionsResult{
|
||||
Collections: make([]string, 0),
|
||||
@@ -532,14 +532,14 @@ func (oper *Operator) listAllCollections(ctx context.Context) ([]string, error)
|
||||
// DeleteColletion
|
||||
type DeleteColletionParams struct {
|
||||
Path string
|
||||
PathAs term.PathUsage `param:"pathAs"`
|
||||
DryRun bool `param:"dryRun"`
|
||||
PathAs string `param:"pathAs"`
|
||||
DryRun bool `param:"dryRun"`
|
||||
}
|
||||
type DeleteColletionResult struct {
|
||||
Files []descr.File `json:"files,omitempty"`
|
||||
}
|
||||
|
||||
func (oper *Operator) DeleteColletion(ctx context.Context, operatorID uint64, param *DeleteColletionParams) (int, *DeleteColletionResult, error) {
|
||||
func (oper *Operator) DeleteColletion(ctx context.Context, operatorID string, param *DeleteColletionParams) (int, *DeleteColletionResult, error) {
|
||||
var err error
|
||||
res := &DeleteColletionResult{
|
||||
Files: make([]descr.File, 0),
|
||||
|
||||
+16
-17
@@ -6,23 +6,22 @@ import (
|
||||
"regexp"
|
||||
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/auxid"
|
||||
)
|
||||
|
||||
// CreateGrant
|
||||
type CreateGrantParams struct {
|
||||
AccountID uint64 `json:"accountID"`
|
||||
Username string `json:"username"`
|
||||
Right term.Right `json:"operation"`
|
||||
Pattern string `json:"pattern"`
|
||||
AccountID string `json:"accountID"`
|
||||
Username string `json:"username"`
|
||||
Right string `json:"operation"`
|
||||
Pattern string `json:"pattern"`
|
||||
}
|
||||
type CreateGrantResult struct {
|
||||
GrantID uint64 `json:"grantId"`
|
||||
GrantID string `json:"grantId"`
|
||||
}
|
||||
|
||||
func (oper *Operator) CreateGrant(ctx context.Context, operatorID uint64, params *CreateGrantParams) (*CreateGrantResult, error) {
|
||||
func (oper *Operator) CreateGrant(ctx context.Context, operatorID string, params *CreateGrantParams) (*CreateGrantResult, error) {
|
||||
var err error
|
||||
res := &CreateGrantResult{}
|
||||
|
||||
@@ -81,7 +80,7 @@ func (oper *Operator) CreateGrant(ctx context.Context, operatorID uint64, params
|
||||
oper.logg.Debugf("Call CreateGrant")
|
||||
now := auxtool.TimeNow()
|
||||
grantDescr := &descr.Grant{
|
||||
ID: uuid.NewUUID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: params.Right,
|
||||
Pattern: params.Pattern,
|
||||
@@ -100,12 +99,12 @@ func (oper *Operator) CreateGrant(ctx context.Context, operatorID uint64, params
|
||||
|
||||
// UpdateGrant
|
||||
type UpdateGrantParams struct {
|
||||
GrantID uint64
|
||||
GrantID string
|
||||
NewPattern string
|
||||
}
|
||||
type UpdateGrantResult struct{}
|
||||
|
||||
func (oper *Operator) UpdateGrant(ctx context.Context, operatorID uint64, params *UpdateGrantParams) (*UpdateGrantResult, error) {
|
||||
func (oper *Operator) UpdateGrant(ctx context.Context, operatorID string, params *UpdateGrantParams) (*UpdateGrantResult, error) {
|
||||
var err error
|
||||
res := &UpdateGrantResult{}
|
||||
|
||||
@@ -143,11 +142,11 @@ func (oper *Operator) UpdateGrant(ctx context.Context, operatorID uint64, params
|
||||
|
||||
// DeleteGrant
|
||||
type DeleteGrantParams struct {
|
||||
GrantID uint64 `json:"grantId"`
|
||||
GrantID string `json:"grantId"`
|
||||
}
|
||||
type DeleteGrantResult struct{}
|
||||
|
||||
func (oper *Operator) DeleteGrant(ctx context.Context, operatorID uint64, params *DeleteGrantParams) (*DeleteGrantResult, error) {
|
||||
func (oper *Operator) DeleteGrant(ctx context.Context, operatorID string, params *DeleteGrantParams) (*DeleteGrantResult, error) {
|
||||
var err error
|
||||
res := &DeleteGrantResult{}
|
||||
|
||||
@@ -177,13 +176,13 @@ func (oper *Operator) DeleteGrant(ctx context.Context, operatorID uint64, params
|
||||
// ListGrants
|
||||
type ListGrantsParams struct {
|
||||
Username string
|
||||
AccountID uint64
|
||||
AccountID string
|
||||
}
|
||||
type ListGrantsResult struct {
|
||||
Grants []descr.Grant `json:"grants"`
|
||||
}
|
||||
|
||||
func (oper *Operator) ListGrants(ctx context.Context, operatorID uint64, params *ListGrantsParams) (*ListGrantsResult, error) {
|
||||
func (oper *Operator) ListGrants(ctx context.Context, operatorID string, params *ListGrantsParams) (*ListGrantsResult, error) {
|
||||
var err error
|
||||
res := &ListGrantsResult{
|
||||
Grants: make([]descr.Grant, 0),
|
||||
@@ -224,13 +223,13 @@ func (oper *Operator) ListGrants(ctx context.Context, operatorID uint64, params
|
||||
|
||||
// Get Grants
|
||||
type GetGrantParams struct {
|
||||
GrantID uint64 `json:"grantId"`
|
||||
GrantID string `json:"grantId"`
|
||||
}
|
||||
type GetGrantResult struct {
|
||||
Grant *descr.Grant `json:"grant"`
|
||||
}
|
||||
|
||||
func (oper *Operator) GetGrant(ctx context.Context, operatorID uint64, params *GetGrantParams) (*GetGrantResult, error) {
|
||||
func (oper *Operator) GetGrant(ctx context.Context, operatorID string, params *GetGrantParams) (*GetGrantResult, error) {
|
||||
var err error
|
||||
res := &GetGrantResult{}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ package operator
|
||||
|
||||
import (
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/auxid"
|
||||
|
||||
ocidigest "github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
@@ -29,7 +29,7 @@ func descrsFromManifest(name, reference string, manifest *ocispec.Manifest, rawM
|
||||
// Make manifest descriptor
|
||||
manifestDigest := ocidigest.SHA256.FromBytes(rawManifest).String()
|
||||
manifestDescr = descr.Manifest{
|
||||
ID: uuid.NewUUID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
Name: name,
|
||||
Reference: reference,
|
||||
Digest: manifestDigest,
|
||||
@@ -41,7 +41,7 @@ func descrsFromManifest(name, reference string, manifest *ocispec.Manifest, rawM
|
||||
// Make config descriptor
|
||||
ociConfig := manifest.Config
|
||||
configDescr := descr.Blob{
|
||||
ID: uuid.NewUUID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
Name: name,
|
||||
Reference: reference,
|
||||
MediaType: ociConfig.MediaType,
|
||||
@@ -55,7 +55,7 @@ func descrsFromManifest(name, reference string, manifest *ocispec.Manifest, rawM
|
||||
layerMap := make(map[string]bool)
|
||||
for _, layer := range manifest.Layers {
|
||||
blobDescr := descr.Blob{
|
||||
ID: uuid.NewUUID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
Name: name,
|
||||
Reference: reference,
|
||||
MediaType: layer.MediaType,
|
||||
@@ -112,7 +112,7 @@ func layersDiff(name, reference string, existingManifest, incomingManifest *ocis
|
||||
timestamp := auxtool.TimeNow()
|
||||
for _, layer := range newLayers {
|
||||
blobDescr := descr.Blob{
|
||||
ID: uuid.NewUUID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
Name: name,
|
||||
Reference: reference,
|
||||
MediaType: layer.MediaType,
|
||||
@@ -126,7 +126,7 @@ func layersDiff(name, reference string, existingManifest, incomingManifest *ocis
|
||||
// Converting to old blobs
|
||||
for _, layer := range delLayers {
|
||||
blobDescr := descr.Blob{
|
||||
ID: uuid.NewUUID(),
|
||||
ID: auxuuid.NewUUID(),
|
||||
Name: name,
|
||||
Reference: reference,
|
||||
MediaType: layer.MediaType,
|
||||
|
||||
Reference in New Issue
Block a user