right type used

This commit is contained in:
2026-02-20 15:28:26 +02:00
parent 8546ad496f
commit 1c8f6f142c
18 changed files with 146 additions and 144 deletions
+16 -16
View File
@@ -6,8 +6,8 @@ import (
"mstore/pkg/auxpwd"
"mstore/pkg/auxtool"
"mstore/pkg/auxuuid"
"mstore/pkg/descr"
"mstore/pkg/uuid"
)
type CreateAccountParams struct {
@@ -15,10 +15,10 @@ type CreateAccountParams struct {
Password string `json:"password"`
}
type CreateAccountResult struct {
AccountID auxuuid.UUID `json:"accountId"`
AccountID uuid.UUID `json:"accountId"`
}
func (oper *Operator) CreateAccount(ctx context.Context, operatorID auxuuid.UUID, params *CreateAccountParams) (*CreateAccountResult, error) {
func (oper *Operator) CreateAccount(ctx context.Context, operatorID uuid.UUID, params *CreateAccountParams) (*CreateAccountResult, error) {
var err error
res := &CreateAccountResult{}
@@ -43,7 +43,7 @@ func (oper *Operator) CreateAccount(ctx context.Context, operatorID auxuuid.UUID
now := auxtool.TimeNow()
passhash := auxpwd.MakeSHA256Hash([]byte(params.Password))
accountDescr := &descr.Account{
ID: auxuuid.NewUUID(),
ID: uuid.NewUUID(),
Username: params.Username,
Passhash: passhash,
Disabled: false,
@@ -62,14 +62,14 @@ func (oper *Operator) CreateAccount(ctx context.Context, operatorID auxuuid.UUID
// GetAccount
type GetAccountParams struct {
Username string `json:"username"`
AccountID auxuuid.UUID `json:"accountId"`
Username string `json:"username"`
AccountID uuid.UUID `json:"accountId"`
}
type GetAccountResult struct {
Account *descr.AccountShort `json:"account"`
}
func (oper *Operator) GetAccount(ctx context.Context, operatorID auxuuid.UUID, params *GetAccountParams) (*GetAccountResult, error) {
func (oper *Operator) GetAccount(ctx context.Context, operatorID uuid.UUID, params *GetAccountParams) (*GetAccountResult, error) {
var err error
res := &GetAccountResult{}
@@ -128,15 +128,15 @@ func (oper *Operator) GetAccount(ctx context.Context, operatorID auxuuid.UUID, p
}
type UpdateAccountParams struct {
Username string `json:"username"`
AccountID auxuuid.UUID `json:"accountId"`
NewUsername string `json:"newUsername"`
NewPassword string `json:"newPassword"`
Disabled bool `json:"disabled"`
Username string `json:"username"`
AccountID uuid.UUID `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 auxuuid.UUID, params *UpdateAccountParams) (*UpdateAccountResult, error) {
func (oper *Operator) UpdateAccount(ctx context.Context, operatorID uuid.UUID, params *UpdateAccountParams) (*UpdateAccountResult, error) {
var err error
res := &UpdateAccountResult{}
if params.Username == "" && params.AccountID == "" {
@@ -195,12 +195,12 @@ func (oper *Operator) UpdateAccount(ctx context.Context, operatorID auxuuid.UUID
}
type DeleteAccountParams struct {
Username string `json:"username"`
AccountID auxuuid.UUID `json:"accountId"`
Username string `json:"username"`
AccountID uuid.UUID `json:"accountId"`
}
type DeleteAccountResult struct{}
func (oper *Operator) DeleteAccount(ctx context.Context, operatorID auxuuid.UUID, params *DeleteAccountParams) (*DeleteAccountResult, error) {
func (oper *Operator) DeleteAccount(ctx context.Context, operatorID uuid.UUID, params *DeleteAccountParams) (*DeleteAccountResult, error) {
var err error
res := &DeleteAccountResult{}
+3 -3
View File
@@ -16,7 +16,7 @@ import (
"net/http"
"strconv"
"mstore/pkg/auxuuid"
"mstore/pkg/uuid"
)
type BlobExistsParams struct {
@@ -73,7 +73,7 @@ type PostUploadParams struct {
From string
}
type PostUploadResult struct {
DockerUploadUUID auxuuid.UUID
DockerUploadUUID uuid.UUID
Location string
ContentLength string
}
@@ -83,7 +83,7 @@ func (oper *Operator) PostUpload(ctx context.Context, params *PostUploadParams)
res := &PostUploadResult{}
if params.Digest == "" {
uuid := auxuuid.NewUUID()
uuid := uuid.NewUUID()
location := fmt.Sprintf("/v2/%s/blobs/uploads/%s", params.Name, uuid)
res.DockerUploadUUID = uuid
res.Location = location
+13 -13
View File
@@ -22,9 +22,9 @@ import (
"strings"
"mstore/pkg/auxtool"
"mstore/pkg/auxuuid"
"mstore/pkg/descr"
"mstore/pkg/terms"
"mstore/pkg/uuid"
)
// FileInfo
@@ -41,9 +41,9 @@ type FileInfoResult struct {
ContentDigest string
ContentCreatedAt string
ContentCreatedBy auxuuid.UUID
ContentCreatedBy uuid.UUID
ContentUpdatedAt string
ContentUpdatedBy auxuuid.UUID
ContentUpdatedBy uuid.UUID
}
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 auxuuid.UUID, param *FileInfoParams) (int, *FileInfoResult, error) {
func (oper *Operator) FileInfo(ctx context.Context, operatorID uuid.UUID, 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 auxuuid.UUID, param *PutFileParams) (int, *PutFileResult, error) {
func (oper *Operator) PutFile(ctx context.Context, operatorID uuid.UUID, param *PutFileParams) (int, *PutFileResult, error) {
var err error
res := &PutFileResult{}
@@ -155,7 +155,7 @@ func (oper *Operator) PutFile(ctx context.Context, operatorID auxuuid.UUID, para
}
} else {
fileDescr = &descr.File{
ID: auxuuid.NewUUID(),
ID: uuid.NewUUID(),
Name: filename,
Collection: collection,
Size: size,
@@ -193,12 +193,12 @@ type GetFileResult struct {
Source io.ReadCloser
ContentCreatedAt string
ContentCreatedBy auxuuid.UUID
ContentCreatedBy uuid.UUID
ContentUpdatedAt string
ContentUpdatedBy auxuuid.UUID
ContentUpdatedBy uuid.UUID
}
func (oper *Operator) GetFile(ctx context.Context, operatorID auxuuid.UUID, param *GetFileParams) (int, *GetFileResult, error) {
func (oper *Operator) GetFile(ctx context.Context, operatorID uuid.UUID, 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 auxuuid.UUID, param *DeleteFileParams) (int, *DeleteFileResult, error) {
func (oper *Operator) DeleteFile(ctx context.Context, operatorID uuid.UUID, 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 auxuuid.UUID, params *ListFilesParams) (int, *ListFilesResult, error) {
func (oper *Operator) ListFiles(ctx context.Context, operatorID uuid.UUID, 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 auxuuid.UUID, param *ListCollectionsParams) (int, *ListCollectionsResult, error) {
func (oper *Operator) ListCollections(ctx context.Context, operatorID uuid.UUID, 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 auxuuid.UUID, param *DeleteColletionParams) (int, *DeleteColletionResult, error) {
func (oper *Operator) DeleteColletion(ctx context.Context, operatorID uuid.UUID, param *DeleteColletionParams) (int, *DeleteColletionResult, error) {
var err error
res := &DeleteColletionResult{
Files: make([]descr.File, 0),
+17 -16
View File
@@ -6,22 +6,23 @@ import (
"regexp"
"mstore/pkg/auxtool"
"mstore/pkg/auxuuid"
"mstore/pkg/descr"
"mstore/pkg/terms"
"mstore/pkg/uuid"
)
// CreateGrant
type CreateGrantParams struct {
AccountID auxuuid.UUID `json:"accountID"`
Username string `json:"username"`
Right string `json:"operation"`
Pattern string `json:"pattern"`
AccountID uuid.UUID `json:"accountID"`
Username string `json:"username"`
Right terms.Right `json:"operation"`
Pattern string `json:"pattern"`
}
type CreateGrantResult struct {
GrantID auxuuid.UUID `json:"grantId"`
GrantID uuid.UUID `json:"grantId"`
}
func (oper *Operator) CreateGrant(ctx context.Context, operatorID auxuuid.UUID, params *CreateGrantParams) (*CreateGrantResult, error) {
func (oper *Operator) CreateGrant(ctx context.Context, operatorID uuid.UUID, params *CreateGrantParams) (*CreateGrantResult, error) {
var err error
res := &CreateGrantResult{}
@@ -80,7 +81,7 @@ func (oper *Operator) CreateGrant(ctx context.Context, operatorID auxuuid.UUID,
oper.logg.Debugf("Call CreateGrant")
now := auxtool.TimeNow()
grantDescr := &descr.Grant{
ID: auxuuid.NewUUID(),
ID: uuid.NewUUID(),
AccountID: accountDescr.ID,
Right: params.Right,
Pattern: params.Pattern,
@@ -99,12 +100,12 @@ func (oper *Operator) CreateGrant(ctx context.Context, operatorID auxuuid.UUID,
// UpdateGrant
type UpdateGrantParams struct {
GrantID auxuuid.UUID
GrantID uuid.UUID
NewPattern string
}
type UpdateGrantResult struct{}
func (oper *Operator) UpdateGrant(ctx context.Context, operatorID auxuuid.UUID, params *UpdateGrantParams) (*UpdateGrantResult, error) {
func (oper *Operator) UpdateGrant(ctx context.Context, operatorID uuid.UUID, params *UpdateGrantParams) (*UpdateGrantResult, error) {
var err error
res := &UpdateGrantResult{}
@@ -142,11 +143,11 @@ func (oper *Operator) UpdateGrant(ctx context.Context, operatorID auxuuid.UUID,
// DeleteGrant
type DeleteGrantParams struct {
GrantID auxuuid.UUID `json:"grantId"`
GrantID uuid.UUID `json:"grantId"`
}
type DeleteGrantResult struct{}
func (oper *Operator) DeleteGrant(ctx context.Context, operatorID auxuuid.UUID, params *DeleteGrantParams) (*DeleteGrantResult, error) {
func (oper *Operator) DeleteGrant(ctx context.Context, operatorID uuid.UUID, params *DeleteGrantParams) (*DeleteGrantResult, error) {
var err error
res := &DeleteGrantResult{}
@@ -176,13 +177,13 @@ func (oper *Operator) DeleteGrant(ctx context.Context, operatorID auxuuid.UUID,
// ListGrants
type ListGrantsParams struct {
Username string
AccountID auxuuid.UUID
AccountID uuid.UUID
}
type ListGrantsResult struct {
Grants []descr.Grant `json:"grants"`
}
func (oper *Operator) ListGrants(ctx context.Context, operatorID auxuuid.UUID, params *ListGrantsParams) (*ListGrantsResult, error) {
func (oper *Operator) ListGrants(ctx context.Context, operatorID uuid.UUID, params *ListGrantsParams) (*ListGrantsResult, error) {
var err error
res := &ListGrantsResult{
Grants: make([]descr.Grant, 0),
@@ -223,13 +224,13 @@ func (oper *Operator) ListGrants(ctx context.Context, operatorID auxuuid.UUID, p
// Get Grants
type GetGrantParams struct {
GrantID auxuuid.UUID `json:"grantId"`
GrantID uuid.UUID `json:"grantId"`
}
type GetGrantResult struct {
Grant *descr.Grant `json:"grant"`
}
func (oper *Operator) GetGrant(ctx context.Context, operatorID auxuuid.UUID, params *GetGrantParams) (*GetGrantResult, error) {
func (oper *Operator) GetGrant(ctx context.Context, operatorID uuid.UUID, params *GetGrantParams) (*GetGrantResult, error) {
var err error
res := &GetGrantResult{}
+6 -6
View File
@@ -11,8 +11,8 @@ package operator
import (
"mstore/pkg/auxtool"
"mstore/pkg/auxuuid"
"mstore/pkg/descr"
"mstore/pkg/uuid"
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: auxuuid.NewUUID(),
ID: uuid.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: auxuuid.NewUUID(),
ID: uuid.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: auxuuid.NewUUID(),
ID: uuid.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: auxuuid.NewUUID(),
ID: uuid.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: auxuuid.NewUUID(),
ID: uuid.NewUUID(),
Name: name,
Reference: reference,
MediaType: layer.MediaType,