diff --git a/app/handler/aaafunc.go b/app/handler/aaafunc.go index 1cbc20e..7fb4c75 100644 --- a/app/handler/aaafunc.go +++ b/app/handler/aaafunc.go @@ -17,8 +17,8 @@ import ( "mstore/app/router" "mstore/pkg/auxhttp" "mstore/pkg/auxpwd" - "mstore/pkg/auxuuid" "mstore/pkg/terms" + "mstore/pkg/uuid" ) const ( @@ -44,12 +44,12 @@ func (hand *Handler) AuthMiddleware(next router.Handler) router.Handler { } // Authentification -func (hand *Handler) CheckAccess(rctx *router.Context) (bool, auxuuid.UUID, error) { +func (hand *Handler) CheckAccess(rctx *router.Context) (bool, uuid.UUID, error) { var err error var success bool var username string var password string - var accountID auxuuid.UUID + var accountID uuid.UUID accountID = terms.AnonymousID @@ -80,9 +80,9 @@ anonymous: return success, accountID, err } -func (hand *Handler) ValidatePassword(ctx context.Context, username, password string) (bool, auxuuid.UUID, error) { +func (hand *Handler) ValidatePassword(ctx context.Context, username, password string) (bool, uuid.UUID, error) { var err error - var accountID auxuuid.UUID + var accountID uuid.UUID valid := false accountExists, accountDescr, err := hand.mdb.GetAccountByUsername(ctx, username) @@ -102,7 +102,7 @@ func (hand *Handler) ValidatePassword(ctx context.Context, username, password st // Authorization -func (hand *Handler) CheckRight(ctx context.Context, accountID auxuuid.UUID, reqRight, subject string) (bool, error) { +func (hand *Handler) CheckRight(ctx context.Context, accountID uuid.UUID, reqRight terms.Right, subject string) (bool, error) { var err error var res bool //hand.logg.Debugf("Cop check your right %s: %s %s", accountID, reqRight, subject) diff --git a/app/handler/account.go b/app/handler/account.go index 20c32c9..95db7e7 100644 --- a/app/handler/account.go +++ b/app/handler/account.go @@ -14,8 +14,8 @@ import ( "mstore/app/operator" "mstore/app/router" - "mstore/pkg/auxuuid" "mstore/pkg/terms" + "mstore/pkg/uuid" ) // POST /v3/account/create 200 200 @@ -30,7 +30,7 @@ func (hand *Handler) CreateAccount(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteAccounts, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "") if err != nil { err := fmt.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -42,7 +42,7 @@ func (hand *Handler) CreateAccount(rctx *router.Context) { return } // Execution of the operation - res, err := hand.oper.CreateAccount(rctx.Ctx, auxuuid.UUID(operatorID), params) + res, err := hand.oper.CreateAccount(rctx.Ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -63,7 +63,7 @@ func (hand *Handler) GetAccount(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteAccounts, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "") if err != nil { err := fmt.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -75,7 +75,7 @@ func (hand *Handler) GetAccount(rctx *router.Context) { return } // Execution of the operation - res, err := hand.oper.GetAccount(rctx.Ctx, auxuuid.UUID(operatorID), params) + res, err := hand.oper.GetAccount(rctx.Ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -96,7 +96,7 @@ func (hand *Handler) ListAccounts(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteAccounts, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "") if err != nil { err := fmt.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -129,7 +129,7 @@ func (hand *Handler) UpdateAccount(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteAccounts, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "") if err != nil { err := fmt.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -141,7 +141,7 @@ func (hand *Handler) UpdateAccount(rctx *router.Context) { return } // Execution of the operation - res, err := hand.oper.UpdateAccount(rctx.Ctx, auxuuid.UUID(operatorID), params) + res, err := hand.oper.UpdateAccount(rctx.Ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("UpdateAccount error: %v", err) hand.SendError(rctx, err) @@ -162,7 +162,7 @@ func (hand *Handler) DeleteAccount(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteAccounts, params.Username) + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, params.Username) if err != nil { err := fmt.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -174,7 +174,7 @@ func (hand *Handler) DeleteAccount(rctx *router.Context) { return } // Execution of the operation - res, err := hand.oper.DeleteAccount(rctx.Ctx, auxuuid.UUID(operatorID), params) + res, err := hand.oper.DeleteAccount(rctx.Ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("DeleteAccount error: %v", err) hand.SendError(rctx, err) diff --git a/app/handler/blob.go b/app/handler/blob.go index 162a195..4b83696 100644 --- a/app/handler/blob.go +++ b/app/handler/blob.go @@ -16,8 +16,8 @@ import ( "mstore/app/operator" "mstore/app/router" - "mstore/pkg/auxuuid" "mstore/pkg/terms" + "mstore/pkg/uuid" ) // HEAD /v2//blobs/ 200 404 @@ -33,7 +33,7 @@ func (hand *Handler) BlobExists(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -73,7 +73,7 @@ func (hand *Handler) PostUpload(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -118,7 +118,7 @@ func (hand *Handler) PatchUpload(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -162,7 +162,7 @@ func (hand *Handler) PutUpload(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -192,7 +192,7 @@ func (hand *Handler) GetBlob(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -238,7 +238,7 @@ func (hand *Handler) DeleteBlob(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return diff --git a/app/handler/file.go b/app/handler/file.go index 942253b..db50f18 100644 --- a/app/handler/file.go +++ b/app/handler/file.go @@ -15,8 +15,8 @@ import ( "mstore/app/operator" "mstore/app/router" - "mstore/pkg/auxuuid" "mstore/pkg/terms" + "mstore/pkg/uuid" ) const zeroContentLength = "0" @@ -29,7 +29,7 @@ func (hand *Handler) FileInfo(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadFiles, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadFiles, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -40,7 +40,7 @@ func (hand *Handler) FileInfo(rctx *router.Context) { } // Execution of the operation ctx := rctx.GetContext() - code, res, err := hand.oper.FileInfo(ctx, auxuuid.UUID(operatorID), params) + code, res, err := hand.oper.FileInfo(ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("FileInfo error: %v", err) rctx.SetStatus(code) @@ -74,7 +74,7 @@ func (hand *Handler) PutFile(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteFiles, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteFiles, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -85,7 +85,7 @@ func (hand *Handler) PutFile(rctx *router.Context) { } // Execution of the operation ctx := rctx.GetContext() - code, _, err := hand.oper.PutFile(ctx, auxuuid.UUID(operatorID), params) + code, _, err := hand.oper.PutFile(ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("PutFile error: %v", err) rctx.SetStatus(code) @@ -102,7 +102,7 @@ func (hand *Handler) GetFile(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadFiles, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadFiles, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -113,7 +113,7 @@ func (hand *Handler) GetFile(rctx *router.Context) { } // Execution of the operation ctx := rctx.GetContext() - code, res, err := hand.oper.GetFile(ctx, auxuuid.UUID(operatorID), params) + code, res, err := hand.oper.GetFile(ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("PutFile error: %v", err) rctx.SetStatus(code) @@ -150,7 +150,7 @@ func (hand *Handler) DeleteFile(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteFiles, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteFiles, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -161,7 +161,7 @@ func (hand *Handler) DeleteFile(rctx *router.Context) { } // Execution of the operation ctx := rctx.GetContext() - code, _, err := hand.oper.DeleteFile(ctx, auxuuid.UUID(operatorID), params) + code, _, err := hand.oper.DeleteFile(ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("DeleteFIle error: %v", err) } @@ -187,7 +187,7 @@ func (hand *Handler) ListFiles(rctx *router.Context) { // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadFiles, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadFiles, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -198,7 +198,7 @@ func (hand *Handler) ListFiles(rctx *router.Context) { } // Execution of the operation ctx := rctx.GetContext() - code, res, err := hand.oper.ListFiles(ctx, auxuuid.UUID(operatorID), params) + code, res, err := hand.oper.ListFiles(ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("ListFiles error: %v", err) rctx.SetStatus(code) @@ -224,7 +224,7 @@ func (hand *Handler) ListCollections(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadFiles, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadFiles, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -235,7 +235,7 @@ func (hand *Handler) ListCollections(rctx *router.Context) { } // Execution of the operation ctx := rctx.GetContext() - code, res, err := hand.oper.ListCollections(ctx, auxuuid.UUID(operatorID), params) + code, res, err := hand.oper.ListCollections(ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("ListCollections error: %v", err) rctx.SetStatus(code) @@ -262,7 +262,7 @@ func (hand *Handler) DeleteCollection(rctx *router.Context) { // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadFiles, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadFiles, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -273,7 +273,7 @@ func (hand *Handler) DeleteCollection(rctx *router.Context) { } // Execution of the operation ctx := rctx.GetContext() - code, res, err := hand.oper.DeleteColletion(ctx, auxuuid.UUID(operatorID), params) + code, res, err := hand.oper.DeleteColletion(ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("DeleteColletion error: %v", err) rctx.SetStatus(code) diff --git a/app/handler/grant.go b/app/handler/grant.go index 14c11f2..d80630d 100644 --- a/app/handler/grant.go +++ b/app/handler/grant.go @@ -14,8 +14,8 @@ import ( "mstore/app/operator" "mstore/app/router" - "mstore/pkg/auxuuid" "mstore/pkg/terms" + "mstore/pkg/uuid" ) // POST /v3/grant/create 200 200 @@ -30,7 +30,7 @@ func (hand *Handler) CreateGrant(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteAccounts, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "") if err != nil { err := fmt.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -42,7 +42,7 @@ func (hand *Handler) CreateGrant(rctx *router.Context) { return } // Execution of the operation - res, err := hand.oper.CreateGrant(rctx.Ctx, auxuuid.UUID(operatorID), params) + res, err := hand.oper.CreateGrant(rctx.Ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("CreateGrant error: %v", err) hand.SendError(rctx, err) @@ -63,7 +63,7 @@ func (hand *Handler) GetGrant(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadAccounts, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadAccounts, "") if err != nil { err := fmt.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -75,7 +75,7 @@ func (hand *Handler) GetGrant(rctx *router.Context) { return } // Execution of the operation - res, err := hand.oper.GetGrant(rctx.Ctx, auxuuid.UUID(operatorID), params) + res, err := hand.oper.GetGrant(rctx.Ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("CreateGrant error: %v", err) hand.SendError(rctx, err) @@ -96,7 +96,7 @@ func (hand *Handler) ListGrants(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadAccounts, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadAccounts, "") if err != nil { err := fmt.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -108,7 +108,7 @@ func (hand *Handler) ListGrants(rctx *router.Context) { return } // Execution of the operation - res, err := hand.oper.ListGrants(rctx.Ctx, auxuuid.UUID(operatorID), params) + res, err := hand.oper.ListGrants(rctx.Ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("ListGrants error: %v", err) hand.SendError(rctx, err) @@ -129,7 +129,7 @@ func (hand *Handler) UpdateGrant(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteAccounts, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "") if err != nil { err := fmt.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -141,7 +141,7 @@ func (hand *Handler) UpdateGrant(rctx *router.Context) { return } // Execution of the operation - res, err := hand.oper.UpdateGrant(rctx.Ctx, auxuuid.UUID(operatorID), params) + res, err := hand.oper.UpdateGrant(rctx.Ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("UpdateGrant error: %v", err) hand.SendError(rctx, err) @@ -162,7 +162,7 @@ func (hand *Handler) DeleteGrant(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteAccounts, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "") if err != nil { err := fmt.Errorf("Operation error: %v", err) hand.SendError(rctx, err) @@ -174,7 +174,7 @@ func (hand *Handler) DeleteGrant(rctx *router.Context) { return } // Execution of the operation - res, err := hand.oper.DeleteGrant(rctx.Ctx, auxuuid.UUID(operatorID), params) + res, err := hand.oper.DeleteGrant(rctx.Ctx, uuid.UUID(operatorID), params) if err != nil { hand.logg.Errorf("DeleteGrant error: %v", err) hand.SendError(rctx, err) diff --git a/app/handler/manifest.go b/app/handler/manifest.go index c04c061..fc0d273 100644 --- a/app/handler/manifest.go +++ b/app/handler/manifest.go @@ -14,8 +14,8 @@ import ( "mstore/app/operator" "mstore/app/router" - "mstore/pkg/auxuuid" "mstore/pkg/terms" + "mstore/pkg/uuid" ) func (hand *Handler) ManifestExists(rctx *router.Context) { @@ -30,7 +30,7 @@ func (hand *Handler) ManifestExists(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -72,7 +72,7 @@ func (hand *Handler) PutManifest(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -105,7 +105,7 @@ func (hand *Handler) GetManifest(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -145,7 +145,7 @@ func (hand *Handler) DeleteManifest(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightWriteImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -174,7 +174,7 @@ func (hand *Handler) GetReferer(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return @@ -200,7 +200,7 @@ func (hand *Handler) GetTags(rctx *router.Context) { } // Rigth checking operatorID, _ := rctx.GetString(userTag) - opEnable, err := hand.CheckRight(rctx.Ctx, auxuuid.UUID(operatorID), terms.RightReadImages, "") + opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "") if err != nil { rctx.SetStatus(http.StatusInternalServerError) return diff --git a/app/maindb/account.go b/app/maindb/account.go index b9afc55..9bab3e8 100644 --- a/app/maindb/account.go +++ b/app/maindb/account.go @@ -3,8 +3,8 @@ package maindb import ( "context" - "mstore/pkg/auxuuid" "mstore/pkg/descr" + "mstore/pkg/uuid" ) func (db *Database) InsertAccount(ctx context.Context, account *descr.Account) error { @@ -20,7 +20,7 @@ func (db *Database) InsertAccount(ctx context.Context, account *descr.Account) e return err } -func (db *Database) UpdateAccountByID(ctx context.Context, accountID auxuuid.UUID, account *descr.Account) error { +func (db *Database) UpdateAccountByID(ctx context.Context, accountID uuid.UUID, account *descr.Account) error { var err error request := `UPDATE accounts SET username = $1, passhash = $2, disabled = $3, updated_at = $4, updated_by = $5 WHERE id = $6` _, err = db.db.Exec(request, account.Username, account.Passhash, account.Disabled, account.UpdatedAt, account.UpdatedBy, accountID) @@ -52,7 +52,7 @@ func (db *Database) ListAccounts(ctx context.Context) ([]descr.Account, error) { return res, err } -func (db *Database) GetAccountByID(ctx context.Context, accountID auxuuid.UUID) (bool, *descr.Account, error) { +func (db *Database) GetAccountByID(ctx context.Context, accountID uuid.UUID) (bool, *descr.Account, error) { var err error var res *descr.Account var exists bool = false @@ -91,7 +91,7 @@ func (db *Database) GetAccountByUsername(ctx context.Context, username string) ( return exists, res, err } -func (db *Database) DeleteAccountByID(ctx context.Context, accountID auxuuid.UUID) error { +func (db *Database) DeleteAccountByID(ctx context.Context, accountID uuid.UUID) error { var err error request := `DELETE FROM accounts WHERE id = $1` diff --git a/app/maindb/file.go b/app/maindb/file.go index 2722b50..95baa1b 100644 --- a/app/maindb/file.go +++ b/app/maindb/file.go @@ -12,8 +12,8 @@ package maindb import ( "context" - "mstore/pkg/auxuuid" "mstore/pkg/descr" + "mstore/pkg/uuid" ) func (db *Database) InsertFile(ctx context.Context, file *descr.File) error { @@ -28,7 +28,7 @@ func (db *Database) InsertFile(ctx context.Context, file *descr.File) error { return err } -func (db *Database) UpdateFileByID(ctx context.Context, fileID auxuuid.UUID, file *descr.File) error { +func (db *Database) UpdateFileByID(ctx context.Context, fileID uuid.UUID, file *descr.File) error { var err error request := `UPDATE files SET id = $1, collection = $2, name = $3, type = $4, checksum = $5, size = $6, updated_at = $7, created_by = $8, updated_by = $9 diff --git a/app/maindb/file_test.go b/app/maindb/file_test.go index 30ff1a3..5af0222 100644 --- a/app/maindb/file_test.go +++ b/app/maindb/file_test.go @@ -15,8 +15,8 @@ import ( "time" "mstore/pkg/auxtool" - "mstore/pkg/auxuuid" "mstore/pkg/descr" + "mstore/pkg/uuid" "github.com/stretchr/testify/require" ) @@ -33,9 +33,9 @@ func TestFile(t *testing.T) { err = db.InitDatabase() require.NoError(t, err) - id := auxuuid.NewUUID() + id := uuid.NewUUID() timenow := auxtool.TimeNow() - creator := auxuuid.NewUUID() + creator := uuid.NewUUID() collection := "foo" newFile := &descr.File{ ID: id, diff --git a/app/maindb/grant.go b/app/maindb/grant.go index 24849cd..1a6f4d6 100644 --- a/app/maindb/grant.go +++ b/app/maindb/grant.go @@ -12,8 +12,9 @@ package maindb import ( "context" - "mstore/pkg/auxuuid" "mstore/pkg/descr" + "mstore/pkg/terms" + "mstore/pkg/uuid" ) func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error { @@ -28,7 +29,7 @@ func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error { return err } -func (db *Database) UpdateGrantByID(ctx context.Context, grantID auxuuid.UUID, grant *descr.Grant) error { +func (db *Database) UpdateGrantByID(ctx context.Context, grantID uuid.UUID, grant *descr.Grant) error { var err error request := `UPDATE grants SET pattern = $1, updated_at = $2, updated_by = $3 WHERE id = $4` _, err = db.db.Exec(request, grant.Pattern, grant.UpdatedAt, grant.UpdatedBy, grantID) @@ -38,7 +39,7 @@ func (db *Database) UpdateGrantByID(ctx context.Context, grantID auxuuid.UUID, g return err } -func (db *Database) ListGrantsByAccountID(ctx context.Context, accountID auxuuid.UUID) ([]descr.Grant, error) { +func (db *Database) ListGrantsByAccountID(ctx context.Context, accountID uuid.UUID) ([]descr.Grant, error) { var err error request := `SELECT * FROM grants WHERE account_id = $1` res := make([]descr.Grant, 0) @@ -60,7 +61,7 @@ func (db *Database) ListGrants(ctx context.Context) ([]descr.Grant, error) { return res, err } -func (db *Database) GetGrantByID(ctx context.Context, id auxuuid.UUID) (bool, *descr.Grant, error) { +func (db *Database) GetGrantByID(ctx context.Context, id uuid.UUID) (bool, *descr.Grant, error) { var err error res := &descr.Grant{} request := `SELECT * FROM grants WHERE id = $1 LIMIT 1` @@ -77,7 +78,7 @@ func (db *Database) GetGrantByID(ctx context.Context, id auxuuid.UUID) (bool, *d return true, res, err } -func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID auxuuid.UUID, right string) (bool, *descr.Grant, error) { +func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right terms.Right) (bool, *descr.Grant, error) { var err error res := &descr.Grant{} request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 LIMIT 1` @@ -94,7 +95,7 @@ func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID auxu return true, res, err } -func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID auxuuid.UUID, right string) (bool, []descr.Grant, error) { +func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right terms.Right) (bool, []descr.Grant, error) { var err error request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2` res := make([]descr.Grant, 0) @@ -108,7 +109,7 @@ func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID au return true, res, err } -func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, accountID auxuuid.UUID, right, pattern string) (bool, *descr.Grant, error) { +func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, accountID uuid.UUID, right terms.Right, pattern string) (bool, *descr.Grant, error) { var err error res := &descr.Grant{} request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 AND pattern = $3 LIMIT 1` @@ -125,7 +126,7 @@ func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, account return true, res, err } -func (db *Database) DeleteGrantByAccountIDRightPattern(ctx context.Context, accountID auxuuid.UUID, right, pattern string) error { +func (db *Database) DeleteGrantByAccountIDRightPattern(ctx context.Context, accountID uuid.UUID, right, pattern string) error { var err error request := `DELETE FROM grants WHERE account_id = $1 AND right = $2 AND pattern = $3` _, err = db.db.Exec(request, accountID, right, pattern) @@ -135,7 +136,7 @@ func (db *Database) DeleteGrantByAccountIDRightPattern(ctx context.Context, acco return err } -func (db *Database) DeleteGrantByID(ctx context.Context, grantID auxuuid.UUID) error { +func (db *Database) DeleteGrantByID(ctx context.Context, grantID uuid.UUID) error { var err error request := `DELETE FROM grants WHERE id = $1` _, err = db.db.Exec(request, grantID) @@ -145,7 +146,7 @@ func (db *Database) DeleteGrantByID(ctx context.Context, grantID auxuuid.UUID) e return err } -func (db *Database) DeleteAllGrantsForAccountID(ctx context.Context, grantID auxuuid.UUID) error { +func (db *Database) DeleteAllGrantsForAccountID(ctx context.Context, grantID uuid.UUID) error { var err error request := `DELETE FROM grants WHERE account_id = $1` _, err = db.db.Exec(request, grantID) diff --git a/app/maindb/grant_test.go b/app/maindb/grant_test.go index 884336c..e2a62cf 100644 --- a/app/maindb/grant_test.go +++ b/app/maindb/grant_test.go @@ -16,8 +16,8 @@ import ( "time" "mstore/pkg/auxtool" - "mstore/pkg/auxuuid" "mstore/pkg/descr" + "mstore/pkg/uuid" "github.com/stretchr/testify/require" ) @@ -34,10 +34,10 @@ func TestGrant(t *testing.T) { err = db.InitDatabase() require.NoError(t, err) - id := auxuuid.NewUUID() - accountID := auxuuid.NewUUID() + id := uuid.NewUUID() + accountID := uuid.NewUUID() timenow := auxtool.TimeNow() - creator := auxuuid.NewUUID() + creator := uuid.NewUUID() newGrant := &descr.Grant{ ID: id, AccountID: accountID, diff --git a/app/maindb/init.go b/app/maindb/init.go index ee7a5e5..ffeeb25 100644 --- a/app/maindb/init.go +++ b/app/maindb/init.go @@ -15,9 +15,9 @@ import ( "mstore/pkg/auxpwd" "mstore/pkg/auxtool" - "mstore/pkg/auxuuid" "mstore/pkg/descr" "mstore/pkg/terms" + "mstore/pkg/uuid" ) func (db *Database) WriteAnonymous(ctx context.Context) error { @@ -41,7 +41,7 @@ func (db *Database) WriteAnonymous(ctx context.Context) error { return err } grantDescr := &descr.Grant{ - ID: auxuuid.NewUUID(), + ID: uuid.NewUUID(), AccountID: accountDescr.ID, Right: terms.RightReadFiles, Pattern: ".*", @@ -55,7 +55,7 @@ func (db *Database) WriteAnonymous(ctx context.Context) error { return err } grantDescr = &descr.Grant{ - ID: auxuuid.NewUUID(), + ID: uuid.NewUUID(), AccountID: accountDescr.ID, Right: terms.RightReadImages, Pattern: ".*", @@ -93,7 +93,7 @@ func (db *Database) WriteInituser(ctx context.Context) error { } // Files grantDescr := &descr.Grant{ - ID: auxuuid.NewUUID(), + ID: uuid.NewUUID(), AccountID: accountDescr.ID, Right: terms.RightReadFiles, Pattern: ".*", @@ -107,7 +107,7 @@ func (db *Database) WriteInituser(ctx context.Context) error { return err } grantDescr = &descr.Grant{ - ID: auxuuid.NewUUID(), + ID: uuid.NewUUID(), AccountID: accountDescr.ID, Right: terms.RightWriteFiles, Pattern: ".*", @@ -122,7 +122,7 @@ func (db *Database) WriteInituser(ctx context.Context) error { } // Accounts grantDescr = &descr.Grant{ - ID: auxuuid.NewUUID(), + ID: uuid.NewUUID(), AccountID: accountDescr.ID, Right: terms.RightReadAccounts, Pattern: ".*", @@ -136,7 +136,7 @@ func (db *Database) WriteInituser(ctx context.Context) error { return err } grantDescr = &descr.Grant{ - ID: auxuuid.NewUUID(), + ID: uuid.NewUUID(), AccountID: accountDescr.ID, Right: terms.RightWriteAccounts, Pattern: ".*", @@ -151,7 +151,7 @@ func (db *Database) WriteInituser(ctx context.Context) error { } // Images grantDescr = &descr.Grant{ - ID: auxuuid.NewUUID(), + ID: uuid.NewUUID(), AccountID: accountDescr.ID, Right: terms.RightReadImages, Pattern: ".*", @@ -165,7 +165,7 @@ func (db *Database) WriteInituser(ctx context.Context) error { return err } grantDescr = &descr.Grant{ - ID: auxuuid.NewUUID(), + ID: uuid.NewUUID(), AccountID: accountDescr.ID, Right: terms.RightWriteImages, Pattern: ".*", diff --git a/app/operator/account.go b/app/operator/account.go index 3a34f9f..752583c 100644 --- a/app/operator/account.go +++ b/app/operator/account.go @@ -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{} diff --git a/app/operator/blob.go b/app/operator/blob.go index 1f00ce4..b20fa8b 100644 --- a/app/operator/blob.go +++ b/app/operator/blob.go @@ -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 diff --git a/app/operator/file.go b/app/operator/file.go index bee6231..ac5c3b4 100644 --- a/app/operator/file.go +++ b/app/operator/file.go @@ -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), diff --git a/app/operator/grant.go b/app/operator/grant.go index 191900b..1694b8c 100644 --- a/app/operator/grant.go +++ b/app/operator/grant.go @@ -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{} diff --git a/app/operator/ociaux.go b/app/operator/ociaux.go index a9ff8bc..2275196 100644 --- a/app/operator/ociaux.go +++ b/app/operator/ociaux.go @@ -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, diff --git a/app/storage/storage.go b/app/storage/storage.go index 1626aed..7c1614c 100644 --- a/app/storage/storage.go +++ b/app/storage/storage.go @@ -20,7 +20,7 @@ import ( "path/filepath" "mstore/app/logger" - "mstore/pkg/auxuuid" + "mstore/pkg/uuid" ) const ( @@ -80,7 +80,7 @@ func (store *Storage) WriteTempFile(source io.Reader) (string, int64, string, er var size int64 var csum string - tmpname := string(auxuuid.NewUUID()) + tmpname := string(uuid.NewUUID()) tmpname = fmt.Sprintf("file-%s.tmp", tmpname) tmppath := store.makeTmppath(tmpname)