mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-22 14:52:17 +01:00
bump beego (#17801)
* bump beego upgrade beego version from v1.10.12 to v2.0.5 1, beego v2 vserver/web refactor 2, beego v2 context refactor 3, beego v2 session refactor 4, beego v2 cache refactor 5, beego v2 orm refactor Signed-off-by: MinerYang <yminer@vmware.com>
This commit is contained in:
parent
68d498f98d
commit
18a3373725
2
Makefile
2
Makefile
@ -523,7 +523,7 @@ GOLANGCI_LINT := $(shell go env GOPATH)/bin/golangci-lint
|
||||
lint:
|
||||
@echo checking lint
|
||||
@echo $(GOLANGCI_LINT)
|
||||
@cd ./src/; $(GOLANGCI_LINT) -v run ./...;
|
||||
@cd ./src/; $(GOLANGCI_LINT) -v run ./... --timeout=10m;
|
||||
|
||||
# go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||
GOVULNCHECK := $(shell go env GOPATH)/bin/govulncheck
|
||||
|
@ -1,14 +1,15 @@
|
||||
package chartserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
beego_cache "github.com/beego/beego/cache"
|
||||
beego_cache "github.com/beego/beego/v2/client/cache"
|
||||
// Enable redis cache adaptor
|
||||
_ "github.com/beego/beego/cache/redis"
|
||||
_ "github.com/beego/beego/v2/client/cache/redis"
|
||||
|
||||
hlog "github.com/goharbor/harbor/src/lib/log"
|
||||
)
|
||||
@ -94,6 +95,7 @@ func (chc *ChartCache) IsEnabled() bool {
|
||||
|
||||
// PutChart caches the detailed data of chart version
|
||||
func (chc *ChartCache) PutChart(chart *ChartVersionDetails) {
|
||||
ctx := context.Background()
|
||||
// If cache is not enabled, do nothing
|
||||
if !chc.IsEnabled() {
|
||||
return
|
||||
@ -107,12 +109,12 @@ func (chc *ChartCache) PutChart(chart *ChartVersionDetails) {
|
||||
switch chc.driverType {
|
||||
case cacheDriverMem:
|
||||
// Directly put object in
|
||||
err = chc.cache.Put(chart.Metadata.Digest, chart, standardExpireTime)
|
||||
err = chc.cache.Put(ctx, chart.Metadata.Digest, chart, standardExpireTime)
|
||||
case cacheDriverRedis, cacheDriverRedisSentinel:
|
||||
// Marshal to json data before saving
|
||||
var jsonData []byte
|
||||
if jsonData, err = json.Marshal(chart); err == nil {
|
||||
err = chc.cache.Put(chart.Metadata.Digest, jsonData, standardExpireTime)
|
||||
err = chc.cache.Put(ctx, chart.Metadata.Digest, jsonData, standardExpireTime)
|
||||
}
|
||||
default:
|
||||
// Should not reach here, but still put guard code here
|
||||
@ -132,11 +134,15 @@ func (chc *ChartCache) PutChart(chart *ChartVersionDetails) {
|
||||
// otherwise, nil object is returned
|
||||
func (chc *ChartCache) GetChart(chartDigest string) *ChartVersionDetails {
|
||||
// If cache is not enabled, do nothing
|
||||
ctx := context.Background()
|
||||
if !chc.IsEnabled() {
|
||||
return nil
|
||||
}
|
||||
|
||||
object := chc.cache.Get(chartDigest)
|
||||
object, err := chc.cache.Get(ctx, chartDigest)
|
||||
if err != nil {
|
||||
hlog.Warningf("Failed to get cache value by key with error: %s", err)
|
||||
}
|
||||
if object != nil {
|
||||
// Try to convert data
|
||||
// First try the normal way
|
||||
|
@ -1,6 +1,7 @@
|
||||
package chartserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -9,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/FZambia/sentinel"
|
||||
"github.com/beego/beego/cache"
|
||||
"github.com/beego/beego/v2/client/cache"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
@ -52,15 +53,16 @@ func (rc *Cache) associate(originKey interface{}) string {
|
||||
}
|
||||
|
||||
// Get cache from redis.
|
||||
func (rc *Cache) Get(key string) interface{} {
|
||||
if v, err := rc.do("GET", key); err == nil {
|
||||
return v
|
||||
func (rc *Cache) Get(ctx context.Context, key string) (interface{}, error) {
|
||||
v, err := rc.do("GET", key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil
|
||||
return v, err
|
||||
}
|
||||
|
||||
// GetMulti get cache from redis.
|
||||
func (rc *Cache) GetMulti(keys []string) []interface{} {
|
||||
func (rc *Cache) GetMulti(ctx context.Context, keys []string) ([]interface{}, error) {
|
||||
c := rc.p.Get()
|
||||
defer c.Close()
|
||||
var args []interface{}
|
||||
@ -69,46 +71,46 @@ func (rc *Cache) GetMulti(keys []string) []interface{} {
|
||||
}
|
||||
values, err := redis.Values(c.Do("MGET", args...))
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
return values
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// Put put cache to redis.
|
||||
func (rc *Cache) Put(key string, val interface{}, timeout time.Duration) error {
|
||||
func (rc *Cache) Put(ctx context.Context, key string, val interface{}, timeout time.Duration) error {
|
||||
_, err := rc.do("SETEX", key, int64(timeout/time.Second), val)
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete delete cache in redis.
|
||||
func (rc *Cache) Delete(key string) error {
|
||||
func (rc *Cache) Delete(ctx context.Context, key string) error {
|
||||
_, err := rc.do("DEL", key)
|
||||
return err
|
||||
}
|
||||
|
||||
// IsExist check cache's existence in redis.
|
||||
func (rc *Cache) IsExist(key string) bool {
|
||||
func (rc *Cache) IsExist(ctx context.Context, key string) (bool, error) {
|
||||
v, err := redis.Bool(rc.do("EXISTS", key))
|
||||
if err != nil {
|
||||
return false
|
||||
return false, err
|
||||
}
|
||||
return v
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Incr increase counter in redis.
|
||||
func (rc *Cache) Incr(key string) error {
|
||||
func (rc *Cache) Incr(ctx context.Context, key string) error {
|
||||
_, err := redis.Bool(rc.do("INCRBY", key, 1))
|
||||
return err
|
||||
}
|
||||
|
||||
// Decr decrease counter in redis.
|
||||
func (rc *Cache) Decr(key string) error {
|
||||
func (rc *Cache) Decr(ctx context.Context, key string) error {
|
||||
_, err := redis.Bool(rc.do("INCRBY", key, -1))
|
||||
return err
|
||||
}
|
||||
|
||||
// ClearAll clean all cache in redis. delete this redis collection.
|
||||
func (rc *Cache) ClearAll() error {
|
||||
func (rc *Cache) ClearAll(ctx context.Context) error {
|
||||
c := rc.p.Get()
|
||||
defer c.Close()
|
||||
cachedKeys, err := redis.Strings(c.Do("KEYS", rc.key+":*"))
|
||||
|
@ -22,8 +22,8 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/beego/beego"
|
||||
"github.com/beego/beego/validation"
|
||||
"github.com/beego/beego/v2/core/validation"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
|
||||
commonhttp "github.com/goharbor/harbor/src/common/http"
|
||||
lib_http "github.com/goharbor/harbor/src/lib/http"
|
||||
@ -40,7 +40,7 @@ const (
|
||||
|
||||
// BaseAPI wraps common methods for controllers to host API
|
||||
type BaseAPI struct {
|
||||
beego.Controller
|
||||
web.Controller
|
||||
}
|
||||
|
||||
// Context returns the context.Context from http.Request
|
||||
@ -79,10 +79,10 @@ func (b *BaseAPI) RenderError(code int, text string) {
|
||||
|
||||
// DecodeJSONReq decodes a json request
|
||||
func (b *BaseAPI) DecodeJSONReq(v interface{}) error {
|
||||
err := json.Unmarshal(b.Ctx.Input.CopyBody(1<<32), v)
|
||||
err := json.Unmarshal(b.Ctx.Input.CopyBody(1<<35), v)
|
||||
if err != nil {
|
||||
log.Errorf("Error while decoding the json request, error: %v, %v",
|
||||
err, string(b.Ctx.Input.CopyBody(1 << 32)[:]))
|
||||
err, string(b.Ctx.Input.CopyBody(1 << 35)[:]))
|
||||
return errors.New("invalid json request")
|
||||
}
|
||||
return nil
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
|
@ -19,8 +19,8 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
libOrm "github.com/goharbor/harbor/src/lib/orm"
|
||||
@ -29,7 +29,7 @@ import (
|
||||
|
||||
var testCtx context.Context
|
||||
|
||||
func execUpdate(o orm.Ormer, sql string, params ...interface{}) error {
|
||||
func execUpdate(o orm.TxOrmer, sql string, params ...interface{}) error {
|
||||
p, err := o.Raw(sql).Prepare()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -46,9 +46,9 @@ func cleanByUser(username string) {
|
||||
var err error
|
||||
|
||||
o := GetOrmer()
|
||||
o.Begin()
|
||||
txOrm, err := o.Begin()
|
||||
|
||||
err = execUpdate(o, `delete
|
||||
err = execUpdate(txOrm, `delete
|
||||
from project_member
|
||||
where entity_id = (
|
||||
select user_id
|
||||
@ -56,11 +56,11 @@ func cleanByUser(username string) {
|
||||
where username = ?
|
||||
) `, username)
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
txOrm.Rollback()
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
err = execUpdate(o, `delete
|
||||
err = execUpdate(txOrm, `delete
|
||||
from project_member
|
||||
where project_id = (
|
||||
select project_id
|
||||
@ -68,30 +68,30 @@ func cleanByUser(username string) {
|
||||
where name = ?
|
||||
)`, projectName)
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
txOrm.Rollback()
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
err = execUpdate(o, `delete from project where name = ?`, projectName)
|
||||
err = execUpdate(txOrm, `delete from project where name = ?`, projectName)
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
txOrm.Rollback()
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
err = execUpdate(o, `delete from harbor_user where username = ?`, username)
|
||||
err = execUpdate(txOrm, `delete from harbor_user where username = ?`, username)
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
txOrm.Rollback()
|
||||
log.Error(err)
|
||||
}
|
||||
err = execUpdate(o, `delete from replication_policy where id < 99`)
|
||||
err = execUpdate(txOrm, `delete from replication_policy where id < 99`)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
err = execUpdate(o, `delete from registry where id < 99`)
|
||||
err = execUpdate(txOrm, `delete from registry where id < 99`)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
o.Commit()
|
||||
txOrm.Commit()
|
||||
}
|
||||
|
||||
const username string = "Tester01"
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
_ "github.com/go-sql-driver/mysql" // register mysql driver
|
||||
|
||||
"github.com/goharbor/harbor/src/common/utils"
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
migrate "github.com/golang-migrate/migrate/v4"
|
||||
_ "github.com/golang-migrate/migrate/v4/database/pgx" // import pgx driver for migrator
|
||||
_ "github.com/golang-migrate/migrate/v4/source/file" // import local file driver for migrator
|
||||
@ -91,17 +91,11 @@ func (p *pgsql) Register(alias ...string) error {
|
||||
info := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=%s timezone=UTC",
|
||||
p.host, p.port, p.usr, p.pwd, p.database, p.sslmode)
|
||||
|
||||
if err := orm.RegisterDataBase(an, "pgx", info, p.maxIdleConns, p.maxOpenConns); err != nil {
|
||||
if err := orm.RegisterDataBase(an, "pgx", info, orm.MaxIdleConnections(p.maxIdleConns),
|
||||
orm.MaxOpenConnections(p.maxOpenConns), orm.ConnMaxLifetime(5*time.Minute)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Due to the issues of beego v1.12.1 and v1.12.2, we set the max open conns ourselves.
|
||||
// See https://github.com/goharbor/harbor/issues/12403
|
||||
// and https://github.com/beego/beego/issues/4059 for more info.
|
||||
db, _ := orm.GetDB(an)
|
||||
db.SetMaxOpenConns(p.maxOpenConns)
|
||||
db.SetConnMaxLifetime(5 * time.Minute)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func TestMaxOpenConns(t *testing.T) {
|
||||
|
@ -17,7 +17,7 @@ package dao
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/pkg/label/model"
|
||||
|
@ -17,7 +17,7 @@ package dao
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
// _ "github.com/mattn/go-sqlite3" // register sqlite driver
|
||||
)
|
||||
|
||||
|
@ -19,11 +19,14 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
)
|
||||
|
||||
var defaultRegistered = false
|
||||
var o orm.Ormer
|
||||
|
||||
// PrepareTestForMySQL is for test only.
|
||||
func PrepareTestForMySQL() {
|
||||
@ -72,13 +75,14 @@ func PrepareTestForPostgresSQL() {
|
||||
}
|
||||
|
||||
log.Infof("POSTGRES_HOST: %s, POSTGRES_USR: %s, POSTGRES_PORT: %d, POSTGRES_PWD: %s\n", dbHost, dbUser, dbPort, dbPassword)
|
||||
initDatabaseForTest(database)
|
||||
o = initDatabaseForTest(database)
|
||||
}
|
||||
|
||||
func initDatabaseForTest(db *models.Database) {
|
||||
func initDatabaseForTest(db *models.Database) orm.Ormer {
|
||||
database, err := getDatabase(db)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Infof("initializing database: %s", database.String())
|
||||
@ -89,17 +93,18 @@ func initDatabaseForTest(db *models.Database) {
|
||||
alias = "default"
|
||||
}
|
||||
if err := database.Register(alias); err != nil {
|
||||
panic(err)
|
||||
log.Fatal(err)
|
||||
return nil
|
||||
}
|
||||
if err := database.UpgradeSchema(); err != nil {
|
||||
panic(err)
|
||||
log.Fatal(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
if alias != "default" {
|
||||
if err = GetOrmer().Using(alias); err != nil {
|
||||
log.Fatalf("failed to create new orm: %v", err)
|
||||
}
|
||||
return orm.NewOrmUsingDB(alias)
|
||||
}
|
||||
return GetOrmer()
|
||||
}
|
||||
|
||||
// PrepareTestData -- Clean and Create data
|
||||
|
@ -15,7 +15,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
common_dao "github.com/goharbor/harbor/src/common/dao"
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
o "github.com/beego/beego/orm"
|
||||
o "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/controller/artifact"
|
||||
"github.com/goharbor/harbor/src/controller/event"
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/docker/distribution/health"
|
||||
|
||||
httputil "github.com/goharbor/harbor/src/common/http"
|
||||
|
@ -137,7 +137,11 @@ func (b *BaseController) SendPermissionError() {
|
||||
// WriteJSONData writes the JSON data to the client.
|
||||
func (b *BaseController) WriteJSONData(object interface{}) {
|
||||
b.Data["json"] = object
|
||||
b.ServeJSON()
|
||||
if err := b.ServeJSON(); err != nil {
|
||||
log.Errorf("failed to serve json, %v", err)
|
||||
b.SendInternalServerError(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// WriteYamlData writes the yaml data to the client.
|
||||
@ -162,7 +166,11 @@ func (b *BaseController) PopulateUserSession(u models.User) {
|
||||
b.SendError(err)
|
||||
return
|
||||
}
|
||||
b.SetSession(userSessionKey, u)
|
||||
if err := b.SetSession(userSessionKey, u); err != nil {
|
||||
log.Errorf("failed to set user into session, error: %v", err)
|
||||
b.SendError(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Init related objects/configurations for the API controllers
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
bcontext "github.com/beego/beego/context"
|
||||
bcontext "github.com/beego/beego/v2/server/web/context"
|
||||
|
||||
"github.com/goharbor/harbor/src/chartserver"
|
||||
proModels "github.com/goharbor/harbor/src/pkg/project/models"
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/beego/beego"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/dghubble/sling"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/api"
|
||||
@ -84,31 +84,31 @@ func init() {
|
||||
dir := filepath.Dir(file)
|
||||
dir = filepath.Join(dir, "..")
|
||||
apppath, _ := filepath.Abs(dir)
|
||||
beego.BConfig.WebConfig.Session.SessionOn = true
|
||||
beego.TestBeegoInit(apppath)
|
||||
web.BConfig.WebConfig.Session.SessionOn = true
|
||||
web.TestBeegoInit(apppath)
|
||||
|
||||
// Charts are controlled under projects
|
||||
chartRepositoryAPIType := &ChartRepositoryAPI{}
|
||||
beego.Router("/api/chartrepo/health", chartRepositoryAPIType, "get:GetHealthStatus")
|
||||
beego.Router("/api/chartrepo/:repo/charts", chartRepositoryAPIType, "get:ListCharts")
|
||||
beego.Router("/api/chartrepo/:repo/charts/:name", chartRepositoryAPIType, "get:ListChartVersions")
|
||||
beego.Router("/api/chartrepo/:repo/charts/:name", chartRepositoryAPIType, "delete:DeleteChart")
|
||||
beego.Router("/api/chartrepo/:repo/charts/:name/:version", chartRepositoryAPIType, "get:GetChartVersion")
|
||||
beego.Router("/api/chartrepo/:repo/charts/:name/:version", chartRepositoryAPIType, "delete:DeleteChartVersion")
|
||||
beego.Router("/api/chartrepo/:repo/charts", chartRepositoryAPIType, "post:UploadChartVersion")
|
||||
beego.Router("/api/chartrepo/:repo/prov", chartRepositoryAPIType, "post:UploadChartProvFile")
|
||||
beego.Router("/api/chartrepo/charts", chartRepositoryAPIType, "post:UploadChartVersion")
|
||||
web.Router("/api/chartrepo/health", chartRepositoryAPIType, "get:GetHealthStatus")
|
||||
web.Router("/api/chartrepo/:repo/charts", chartRepositoryAPIType, "get:ListCharts")
|
||||
web.Router("/api/chartrepo/:repo/charts/:name", chartRepositoryAPIType, "get:ListChartVersions")
|
||||
web.Router("/api/chartrepo/:repo/charts/:name", chartRepositoryAPIType, "delete:DeleteChart")
|
||||
web.Router("/api/chartrepo/:repo/charts/:name/:version", chartRepositoryAPIType, "get:GetChartVersion")
|
||||
web.Router("/api/chartrepo/:repo/charts/:name/:version", chartRepositoryAPIType, "delete:DeleteChartVersion")
|
||||
web.Router("/api/chartrepo/:repo/charts", chartRepositoryAPIType, "post:UploadChartVersion")
|
||||
web.Router("/api/chartrepo/:repo/prov", chartRepositoryAPIType, "post:UploadChartProvFile")
|
||||
web.Router("/api/chartrepo/charts", chartRepositoryAPIType, "post:UploadChartVersion")
|
||||
|
||||
// Repository services
|
||||
beego.Router("/chartrepo/:repo/index.yaml", chartRepositoryAPIType, "get:GetIndexByRepo")
|
||||
beego.Router("/chartrepo/index.yaml", chartRepositoryAPIType, "get:GetIndex")
|
||||
beego.Router("/chartrepo/:repo/charts/:filename", chartRepositoryAPIType, "get:DownloadChart")
|
||||
web.Router("/chartrepo/:repo/index.yaml", chartRepositoryAPIType, "get:GetIndexByRepo")
|
||||
web.Router("/chartrepo/index.yaml", chartRepositoryAPIType, "get:GetIndex")
|
||||
web.Router("/chartrepo/:repo/charts/:filename", chartRepositoryAPIType, "get:DownloadChart")
|
||||
// Labels for chart
|
||||
chartLabelAPIType := &ChartLabelAPI{}
|
||||
beego.Router("/api/"+api.APIVersion+"/chartrepo/:repo/charts/:name/:version/labels", chartLabelAPIType, "get:GetLabels;post:MarkLabel")
|
||||
beego.Router("/api/"+api.APIVersion+"/chartrepo/:repo/charts/:name/:version/labels/:id([0-9]+)", chartLabelAPIType, "delete:RemoveLabel")
|
||||
web.Router("/api/"+api.APIVersion+"/chartrepo/:repo/charts/:name/:version/labels", chartLabelAPIType, "get:GetLabels;post:MarkLabel")
|
||||
web.Router("/api/"+api.APIVersion+"/chartrepo/:repo/charts/:name/:version/labels/:id([0-9]+)", chartLabelAPIType, "delete:RemoveLabel")
|
||||
|
||||
beego.Router("/api/internal/syncquota", &InternalAPI{}, "post:SyncQuota")
|
||||
web.Router("/api/internal/syncquota", &InternalAPI{}, "post:SyncQuota")
|
||||
|
||||
// Init user Info
|
||||
admin = &usrInfo{adminName, adminPwd}
|
||||
@ -120,7 +120,7 @@ func init() {
|
||||
defer mockServer.Close()
|
||||
|
||||
chain := middleware.Chain(orm.Middleware(), security.Middleware(), security.UnauthorizedMiddleware())
|
||||
handler = chain(beego.BeeApp.Handlers)
|
||||
handler = chain(web.BeeApp.Handlers)
|
||||
}
|
||||
|
||||
func request0(_sling *sling.Sling, acceptHeader string, authInfo ...usrInfo) (int, http.Header, []byte, error) {
|
||||
|
@ -17,7 +17,7 @@ package api
|
||||
import (
|
||||
"context"
|
||||
|
||||
o "github.com/beego/beego/orm"
|
||||
o "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
@ -66,7 +66,10 @@ func (ia *InternalAPI) RenameAdmin() {
|
||||
return
|
||||
}
|
||||
log.Debugf("The super user has been renamed to: %s", newName)
|
||||
ia.DestroySession()
|
||||
if err := ia.DestroySession(); err != nil {
|
||||
log.Errorf("failed to destroy session for admin user, error: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// SyncQuota ...
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/core/label"
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
pkg_label "github.com/goharbor/harbor/src/pkg/label"
|
||||
"github.com/goharbor/harbor/src/pkg/label/model"
|
||||
)
|
||||
@ -34,7 +35,11 @@ func (lra *LabelResourceAPI) getLabelsOfResource(rType string, rIDOrName interfa
|
||||
}
|
||||
|
||||
lra.Data["json"] = labels
|
||||
lra.ServeJSON()
|
||||
if err := lra.ServeJSON(); err != nil {
|
||||
log.Errorf("failed to serve json, %v", err)
|
||||
lra.handleErrors(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (lra *LabelResourceAPI) markLabelToResource(rl *models.ResourceLabel) {
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/i18n"
|
||||
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
@ -110,7 +110,10 @@ func (cc *CommonController) Login() {
|
||||
|
||||
// LogOut Habor UI
|
||||
func (cc *CommonController) LogOut() {
|
||||
cc.DestroySession()
|
||||
if err := cc.DestroySession(); err != nil {
|
||||
log.Errorf("Error occurred in LogOut: %v", err)
|
||||
cc.CustomAbort(http.StatusInternalServerError, "Internal error.")
|
||||
}
|
||||
}
|
||||
|
||||
// UserExists checks if user exists when user input value in sign in form.
|
||||
@ -143,7 +146,10 @@ func (cc *CommonController) UserExists() {
|
||||
cc.CustomAbort(http.StatusInternalServerError, "Internal error.")
|
||||
}
|
||||
cc.Data["json"] = n > 0
|
||||
cc.ServeJSON()
|
||||
if err := cc.ServeJSON(); err != nil {
|
||||
log.Errorf("failed to serve json: %v", err)
|
||||
cc.CustomAbort(http.StatusInternalServerError, "Internal error.")
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -151,7 +157,7 @@ func init() {
|
||||
configPath := os.Getenv("CONFIG_PATH")
|
||||
if len(configPath) != 0 {
|
||||
log.Infof("Config path: %s", configPath)
|
||||
if err := beego.LoadAppConfig("ini", configPath); err != nil {
|
||||
if err := web.LoadAppConfig("ini", configPath); err != nil {
|
||||
log.Errorf("failed to load app config: %v", err)
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
@ -41,13 +41,13 @@ func init() {
|
||||
dir := filepath.Dir(file)
|
||||
dir = filepath.Join(dir, "..")
|
||||
apppath, _ := filepath.Abs(dir)
|
||||
beego.BConfig.WebConfig.Session.SessionOn = true
|
||||
beego.TestBeegoInit(apppath)
|
||||
beego.AddTemplateExt("htm")
|
||||
web.BConfig.WebConfig.Session.SessionOn = true
|
||||
web.TestBeegoInit(apppath)
|
||||
web.AddTemplateExt("htm")
|
||||
|
||||
beego.Router("/c/login", &CommonController{}, "post:Login")
|
||||
beego.Router("/c/log_out", &CommonController{}, "get:LogOut")
|
||||
beego.Router("/c/userExists", &CommonController{}, "post:UserExists")
|
||||
web.Router("/c/login", &CommonController{}, "post:Login")
|
||||
web.Router("/c/log_out", &CommonController{}, "get:LogOut")
|
||||
web.Router("/c/userExists", &CommonController{}, "post:UserExists")
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@ -71,7 +71,7 @@ func TestRedirectForOIDC(t *testing.T) {
|
||||
func TestAll(t *testing.T) {
|
||||
config.InitWithSettings(utilstest.GetUnitTestConfig())
|
||||
assert := assert.New(t)
|
||||
handler := http.Handler(beego.BeeApp.Handlers)
|
||||
handler := http.Handler(web.BeeApp.Handlers)
|
||||
mws := middlewares.MiddleWares()
|
||||
for i := len(mws) - 1; i >= 0; i-- {
|
||||
if mws[i] == nil {
|
||||
|
@ -15,12 +15,12 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/beego/beego"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// ErrorController handles beego error pages
|
||||
type ErrorController struct {
|
||||
beego.Controller
|
||||
web.Controller
|
||||
}
|
||||
|
||||
// Error404 renders the 404 page
|
||||
|
@ -63,8 +63,16 @@ func (oc *OIDCController) RedirectLogin() {
|
||||
oc.SendInternalServerError(err)
|
||||
return
|
||||
}
|
||||
oc.SetSession(redirectURLKey, oc.Ctx.Request.URL.Query().Get("redirect_url"))
|
||||
oc.SetSession(stateKey, state)
|
||||
if err := oc.SetSession(redirectURLKey, oc.Ctx.Request.URL.Query().Get("redirect_url")); err != nil {
|
||||
log.Errorf("failed to set session for key: %s, error: %v", redirectURLKey, err)
|
||||
oc.SendInternalServerError(err)
|
||||
return
|
||||
}
|
||||
if err := oc.SetSession(stateKey, state); err != nil {
|
||||
log.Errorf("failed to set session for key: %s, error: %v", stateKey, err)
|
||||
oc.SendInternalServerError(err)
|
||||
return
|
||||
}
|
||||
log.Debugf("State dumped to session: %s", state)
|
||||
// Force to use the func 'Redirect' of beego.Controller
|
||||
oc.Controller.Redirect(url, http.StatusFound)
|
||||
@ -91,7 +99,11 @@ func (oc *OIDCController) Callback() {
|
||||
redirectURL := oc.GetSession(redirectURLKey)
|
||||
if redirectURL != nil {
|
||||
redirectURLStr = redirectURL.(string)
|
||||
oc.DelSession(redirectURLKey)
|
||||
if err := oc.DelSession(redirectURLKey); err != nil {
|
||||
log.Errorf("failed to delete session for key:%s, error: %v", redirectURLKey, err)
|
||||
oc.SendInternalServerError(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
code := oc.Ctx.Request.URL.Query().Get("code")
|
||||
ctx := oc.Ctx.Request.Context()
|
||||
@ -122,7 +134,11 @@ func (oc *OIDCController) Callback() {
|
||||
oc.SendInternalServerError(err)
|
||||
return
|
||||
}
|
||||
oc.SetSession(tokenKey, tokenBytes)
|
||||
if err := oc.SetSession(tokenKey, tokenBytes); err != nil {
|
||||
log.Errorf("failed to set session for key: %s, error: %v", tokenKey, err)
|
||||
oc.SendInternalServerError(err)
|
||||
return
|
||||
}
|
||||
u, err := ctluser.Ctl.GetBySubIss(ctx, info.Subject, info.Issuer)
|
||||
if errors.IsNotFoundErr(err) { // User is not onboarded, kickoff the onboard flow
|
||||
// Recover the username from d.Username by default
|
||||
@ -150,7 +166,11 @@ func (oc *OIDCController) Callback() {
|
||||
log.Debug("User automatically onboarded\n")
|
||||
u = userRec
|
||||
} else {
|
||||
oc.SetSession(userInfoKey, string(ouDataStr))
|
||||
if err := oc.SetSession(userInfoKey, string(ouDataStr)); err != nil {
|
||||
log.Errorf("failed to set session for key: %s, error: %v", userInfoKey, err)
|
||||
oc.SendInternalServerError(err)
|
||||
return
|
||||
}
|
||||
oc.Controller.Redirect(fmt.Sprintf("/oidc-onboard?username=%s&redirect_url=%s", username, redirectURLStr), http.StatusFound)
|
||||
// Once redirected, no further actions are done
|
||||
return
|
||||
@ -253,7 +273,11 @@ func (oc *OIDCController) Onboard() {
|
||||
ctx := oc.Ctx.Request.Context()
|
||||
if user, onboarded := userOnboard(ctx, oc, d, username, tb); onboarded {
|
||||
user.OIDCUserMeta = nil
|
||||
oc.DelSession(userInfoKey)
|
||||
if err := oc.DelSession(userInfoKey); err != nil {
|
||||
log.Errorf("failed to delete session for key:%s, error: %v", userInfoKey, err)
|
||||
oc.SendInternalServerError(err)
|
||||
return
|
||||
}
|
||||
oc.PopulateUserSession(*user)
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
common_http "github.com/goharbor/harbor/src/common/http"
|
||||
@ -120,8 +120,10 @@ func main() {
|
||||
runMode := flag.String("mode", "normal", "The harbor-core container run mode, it could be normal, migrate or skip-migrate, default is normal")
|
||||
flag.Parse()
|
||||
|
||||
beego.BConfig.WebConfig.Session.SessionOn = true
|
||||
beego.BConfig.WebConfig.Session.SessionName = config.SessionCookieName
|
||||
web.BConfig.WebConfig.Session.SessionOn = true
|
||||
web.BConfig.WebConfig.Session.SessionName = config.SessionCookieName
|
||||
web.BConfig.MaxMemory = 1 << 35 // (32GB)
|
||||
web.BConfig.MaxUploadSize = 1 << 35 // (32GB)
|
||||
|
||||
redisURL := os.Getenv("_REDIS_URL_CORE")
|
||||
if len(redisURL) > 0 {
|
||||
@ -130,8 +132,8 @@ func main() {
|
||||
panic("bad _REDIS_URL")
|
||||
}
|
||||
|
||||
beego.BConfig.WebConfig.Session.SessionProvider = session.HarborProviderName
|
||||
beego.BConfig.WebConfig.Session.SessionProviderConfig = redisURL
|
||||
web.BConfig.WebConfig.Session.SessionProvider = session.HarborProviderName
|
||||
web.BConfig.WebConfig.Session.SessionProviderConfig = redisURL
|
||||
|
||||
log.Info("initializing cache ...")
|
||||
if err := cache.Initialize(u.Scheme, redisURL); err != nil {
|
||||
@ -141,7 +143,7 @@ func main() {
|
||||
// enable config cache explicitly when the cache is ready
|
||||
dbCfg.EnableConfigCache()
|
||||
}
|
||||
beego.AddTemplateExt("htm")
|
||||
web.AddTemplateExt("htm")
|
||||
|
||||
log.Info("initializing configurations...")
|
||||
config.Init()
|
||||
@ -223,12 +225,12 @@ func main() {
|
||||
iTLSCertPath := os.Getenv("INTERNAL_TLS_CERT_PATH")
|
||||
|
||||
log.Infof("load client key: %s client cert: %s", iTLSKeyPath, iTLSCertPath)
|
||||
beego.BConfig.Listen.EnableHTTP = false
|
||||
beego.BConfig.Listen.EnableHTTPS = true
|
||||
beego.BConfig.Listen.HTTPSPort = 8443
|
||||
beego.BConfig.Listen.HTTPSKeyFile = iTLSKeyPath
|
||||
beego.BConfig.Listen.HTTPSCertFile = iTLSCertPath
|
||||
beego.BeeApp.Server.TLSConfig = common_http.NewServerTLSConfig()
|
||||
web.BConfig.Listen.EnableHTTP = false
|
||||
web.BConfig.Listen.EnableHTTPS = true
|
||||
web.BConfig.Listen.HTTPSPort = 8443
|
||||
web.BConfig.Listen.HTTPSKeyFile = iTLSKeyPath
|
||||
web.BConfig.Listen.HTTPSCertFile = iTLSCertPath
|
||||
web.BeeApp.Server.TLSConfig = common_http.NewServerTLSConfig()
|
||||
}
|
||||
|
||||
log.Infof("Version: %s, Git commit: %s", version.ReleaseVersion, version.GitCommit)
|
||||
@ -257,7 +259,7 @@ func main() {
|
||||
}
|
||||
systemartifact.ScheduleCleanupTask(ctx)
|
||||
}()
|
||||
beego.RunWithMiddleWares("", middlewares.MiddleWares()...)
|
||||
web.RunWithMiddleWares("", middlewares.MiddleWares()...)
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
||||
"github.com/beego/beego"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
|
||||
"github.com/goharbor/harbor/src/pkg/distribution"
|
||||
"github.com/goharbor/harbor/src/server/middleware"
|
||||
@ -79,8 +79,8 @@ var (
|
||||
)
|
||||
|
||||
// MiddleWares returns global middlewares
|
||||
func MiddleWares() []beego.MiddleWare {
|
||||
return []beego.MiddleWare{
|
||||
func MiddleWares() []web.MiddleWare {
|
||||
return []web.MiddleWare{
|
||||
url.Middleware(),
|
||||
mergeslash.Middleware(),
|
||||
trace.Middleware(),
|
||||
|
@ -19,14 +19,14 @@ import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/beego/beego"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
)
|
||||
|
||||
// Handler handles request on /service/token, which is the auth provider for registry.
|
||||
type Handler struct {
|
||||
beego.Controller
|
||||
web.Controller
|
||||
}
|
||||
|
||||
// Get handles GET request, it checks the http header for user credentials
|
||||
@ -51,5 +51,8 @@ func (h *Handler) Get() {
|
||||
h.CustomAbort(http.StatusInternalServerError, "")
|
||||
}
|
||||
h.Data["json"] = token
|
||||
h.ServeJSON()
|
||||
if err := h.ServeJSON(); err != nil {
|
||||
log.Errorf("failed to serve json on /service/token, %v", err)
|
||||
h.CustomAbort(http.StatusInternalServerError, "")
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ package session
|
||||
import (
|
||||
"encoding/gob"
|
||||
|
||||
"github.com/beego/beego/session"
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
|
||||
commonmodels "github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/lib/cache"
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/session"
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
goredis "github.com/go-redis/redis/v8"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/cache"
|
||||
@ -47,7 +47,7 @@ type Store struct {
|
||||
}
|
||||
|
||||
// Set value in redis session
|
||||
func (rs *Store) Set(key, value interface{}) error {
|
||||
func (rs *Store) Set(ctx context.Context, key, value interface{}) error {
|
||||
rs.lock.Lock()
|
||||
defer rs.lock.Unlock()
|
||||
rs.values[key] = value
|
||||
@ -55,7 +55,7 @@ func (rs *Store) Set(key, value interface{}) error {
|
||||
}
|
||||
|
||||
// Get value in redis session
|
||||
func (rs *Store) Get(key interface{}) interface{} {
|
||||
func (rs *Store) Get(ctx context.Context, key interface{}) interface{} {
|
||||
rs.lock.RLock()
|
||||
defer rs.lock.RUnlock()
|
||||
if v, ok := rs.values[key]; ok {
|
||||
@ -65,7 +65,7 @@ func (rs *Store) Get(key interface{}) interface{} {
|
||||
}
|
||||
|
||||
// Delete value in redis session
|
||||
func (rs *Store) Delete(key interface{}) error {
|
||||
func (rs *Store) Delete(ctx context.Context, key interface{}) error {
|
||||
rs.lock.Lock()
|
||||
defer rs.lock.Unlock()
|
||||
delete(rs.values, key)
|
||||
@ -73,7 +73,7 @@ func (rs *Store) Delete(key interface{}) error {
|
||||
}
|
||||
|
||||
// Flush clear all values in redis session
|
||||
func (rs *Store) Flush() error {
|
||||
func (rs *Store) Flush(ctx context.Context) error {
|
||||
rs.lock.Lock()
|
||||
defer rs.lock.Unlock()
|
||||
rs.values = make(map[interface{}]interface{})
|
||||
@ -81,18 +81,20 @@ func (rs *Store) Flush() error {
|
||||
}
|
||||
|
||||
// SessionID get redis session id
|
||||
func (rs *Store) SessionID() string {
|
||||
func (rs *Store) SessionID(ctx context.Context) string {
|
||||
return rs.sid
|
||||
}
|
||||
|
||||
// SessionRelease save session values to redis
|
||||
func (rs *Store) SessionRelease(w http.ResponseWriter) {
|
||||
func (rs *Store) SessionRelease(ctx context.Context, w http.ResponseWriter) {
|
||||
b, err := session.EncodeGob(rs.values)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
if ctx == nil {
|
||||
ctx = context.TODO()
|
||||
}
|
||||
maxlifetime := time.Duration(systemSessionTimeout(ctx, rs.maxlifetime))
|
||||
if rdb, ok := rs.c.(*redis.Cache); ok {
|
||||
cmd := rdb.Client.Set(ctx, rs.sid, string(b), maxlifetime)
|
||||
@ -109,20 +111,26 @@ type Provider struct {
|
||||
}
|
||||
|
||||
// SessionInit init redis session
|
||||
func (rp *Provider) SessionInit(maxlifetime int64, url string) (err error) {
|
||||
func (rp *Provider) SessionInit(ctx context.Context, maxlifetime int64, url string) (err error) {
|
||||
rp.maxlifetime = maxlifetime * int64(time.Second)
|
||||
rp.c, err = redis.New(cache.Options{Address: url, Codec: codec})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return rp.c.Ping(context.TODO())
|
||||
if ctx == nil {
|
||||
ctx = context.TODO()
|
||||
}
|
||||
return rp.c.Ping(ctx)
|
||||
}
|
||||
|
||||
// SessionRead read redis session by sid
|
||||
func (rp *Provider) SessionRead(sid string) (session.Store, error) {
|
||||
func (rp *Provider) SessionRead(ctx context.Context, sid string) (session.Store, error) {
|
||||
kv := make(map[interface{}]interface{})
|
||||
err := rp.c.Fetch(context.TODO(), sid, &kv)
|
||||
if ctx == nil {
|
||||
ctx = context.TODO()
|
||||
}
|
||||
err := rp.c.Fetch(ctx, sid, &kv)
|
||||
if err != nil && !strings.Contains(err.Error(), goredis.Nil.Error()) {
|
||||
return nil, err
|
||||
}
|
||||
@ -132,16 +140,21 @@ func (rp *Provider) SessionRead(sid string) (session.Store, error) {
|
||||
}
|
||||
|
||||
// SessionExist check redis session exist by sid
|
||||
func (rp *Provider) SessionExist(sid string) bool {
|
||||
return rp.c.Contains(context.TODO(), sid)
|
||||
func (rp *Provider) SessionExist(ctx context.Context, sid string) (bool, error) {
|
||||
if ctx == nil {
|
||||
ctx = context.TODO()
|
||||
}
|
||||
return rp.c.Contains(ctx, sid), nil
|
||||
}
|
||||
|
||||
// SessionRegenerate generate new sid for redis session
|
||||
func (rp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error) {
|
||||
ctx := context.TODO()
|
||||
func (rp *Provider) SessionRegenerate(ctx context.Context, oldsid, sid string) (session.Store, error) {
|
||||
if ctx == nil {
|
||||
ctx = context.TODO()
|
||||
}
|
||||
maxlifetime := time.Duration(systemSessionTimeout(ctx, rp.maxlifetime))
|
||||
if !rp.SessionExist(oldsid) {
|
||||
err := rp.c.Save(ctx, sid, "", maxlifetime)
|
||||
if isExist, _ := rp.SessionExist(ctx, oldsid); !isExist {
|
||||
err := rp.c.Save(ctx, sid, "", time.Duration(rp.maxlifetime))
|
||||
if err != nil {
|
||||
log.Debugf("failed to save sid=%s, where oldsid=%s, error: %s", sid, oldsid, err)
|
||||
}
|
||||
@ -168,20 +181,23 @@ func (rp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error)
|
||||
}
|
||||
}
|
||||
|
||||
return rp.SessionRead(sid)
|
||||
return rp.SessionRead(ctx, sid)
|
||||
}
|
||||
|
||||
// SessionDestroy delete redis session by id
|
||||
func (rp *Provider) SessionDestroy(sid string) error {
|
||||
return rp.c.Delete(context.TODO(), sid)
|
||||
func (rp *Provider) SessionDestroy(ctx context.Context, sid string) error {
|
||||
if ctx == nil {
|
||||
ctx = context.TODO()
|
||||
}
|
||||
return rp.c.Delete(ctx, sid)
|
||||
}
|
||||
|
||||
// SessionGC Implement method, no used.
|
||||
func (rp *Provider) SessionGC() {
|
||||
func (rp *Provider) SessionGC(ctx context.Context) {
|
||||
}
|
||||
|
||||
// SessionAll return all activeSession
|
||||
func (rp *Provider) SessionAll() int {
|
||||
func (rp *Provider) SessionAll(ctx context.Context) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,10 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego/session"
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/config"
|
||||
@ -39,78 +40,83 @@ func (s *sessionTestSuite) SetupSuite() {
|
||||
s.NoError(err, "should get harbor provider")
|
||||
s.NotNil(s.provider, "provider should not nil")
|
||||
|
||||
err = s.provider.SessionInit(3600, "redis://127.0.0.1:6379/0")
|
||||
err = s.provider.SessionInit(context.Background(), 3600, "redis://127.0.0.1:6379/0")
|
||||
s.NoError(err, "session init should not error")
|
||||
}
|
||||
|
||||
func (s *sessionTestSuite) TestSessionRead() {
|
||||
store, err := s.provider.SessionRead("session-001")
|
||||
store, err := s.provider.SessionRead(context.Background(), "session-001")
|
||||
s.NoError(err, "session read should not error")
|
||||
s.NotNil(store)
|
||||
}
|
||||
|
||||
func (s *sessionTestSuite) TestSessionExist() {
|
||||
// prepare session
|
||||
store, err := s.provider.SessionRead("session-001")
|
||||
ctx := context.Background()
|
||||
store, err := s.provider.SessionRead(ctx, "session-001")
|
||||
s.NoError(err, "session read should not error")
|
||||
s.NotNil(store)
|
||||
store.SessionRelease(nil)
|
||||
store.SessionRelease(context.Background(), nil)
|
||||
|
||||
defer func() {
|
||||
// clean session
|
||||
err = s.provider.SessionDestroy("session-001")
|
||||
err = s.provider.SessionDestroy(ctx, "session-001")
|
||||
s.NoError(err)
|
||||
}()
|
||||
|
||||
exist := s.provider.SessionExist("session-001")
|
||||
exist, _ := s.provider.SessionExist(ctx, "session-001")
|
||||
s.True(exist, "session-001 should exist")
|
||||
|
||||
exist = s.provider.SessionExist("session-002")
|
||||
exist, _ = s.provider.SessionExist(ctx, "session-002")
|
||||
s.False(exist, "session-002 should not exist")
|
||||
}
|
||||
|
||||
func (s *sessionTestSuite) TestSessionRegenerate() {
|
||||
// prepare session
|
||||
store, err := s.provider.SessionRead("session-001")
|
||||
ctx := context.Background()
|
||||
store, err := s.provider.SessionRead(ctx, "session-001")
|
||||
s.NoError(err, "session read should not error")
|
||||
s.NotNil(store)
|
||||
store.SessionRelease(nil)
|
||||
store.SessionRelease(ctx, nil)
|
||||
|
||||
defer func() {
|
||||
// clean session
|
||||
err = s.provider.SessionDestroy("session-001")
|
||||
err = s.provider.SessionDestroy(ctx, "session-001")
|
||||
s.NoError(err)
|
||||
|
||||
err = s.provider.SessionDestroy("session-003")
|
||||
err = s.provider.SessionDestroy(ctx, "session-003")
|
||||
s.NoError(err)
|
||||
}()
|
||||
|
||||
_, err = s.provider.SessionRegenerate("session-001", "session-003")
|
||||
_, err = s.provider.SessionRegenerate(ctx, "session-001", "session-003")
|
||||
s.NoError(err, "session regenerate should not error")
|
||||
|
||||
s.True(s.provider.SessionExist("session-003"))
|
||||
s.False(s.provider.SessionExist("session-001"))
|
||||
s.True(s.provider.SessionExist(ctx, "session-003"))
|
||||
s.False(s.provider.SessionExist(ctx, "session-001"))
|
||||
}
|
||||
|
||||
func (s *sessionTestSuite) TestSessionDestroy() {
|
||||
// prepare session
|
||||
store, err := s.provider.SessionRead("session-004")
|
||||
ctx := context.Background()
|
||||
store, err := s.provider.SessionRead(ctx, "session-004")
|
||||
s.NoError(err, "session read should not error")
|
||||
s.NotNil(store)
|
||||
store.SessionRelease(nil)
|
||||
s.True(s.provider.SessionExist("session-004"), "session-004 should exist")
|
||||
store.SessionRelease(ctx, nil)
|
||||
isExist, _ := s.provider.SessionExist(ctx, "session-004")
|
||||
s.True(isExist, "session-004 should exist")
|
||||
|
||||
err = s.provider.SessionDestroy("session-004")
|
||||
err = s.provider.SessionDestroy(ctx, "session-004")
|
||||
s.NoError(err, "session destroy should not error")
|
||||
s.False(s.provider.SessionExist("session-004"), "session-004 should not exist")
|
||||
isExist, _ = s.provider.SessionExist(ctx, "session-004")
|
||||
s.False(isExist, "session-004 should not exist")
|
||||
}
|
||||
|
||||
func (s *sessionTestSuite) TestSessionGC() {
|
||||
s.provider.SessionGC()
|
||||
s.provider.SessionGC(context.Background())
|
||||
}
|
||||
|
||||
func (s *sessionTestSuite) TestSessionAll() {
|
||||
c := s.provider.SessionAll()
|
||||
c := s.provider.SessionAll(context.Background())
|
||||
s.Equal(0, c)
|
||||
}
|
||||
|
||||
|
16
src/go.mod
16
src/go.mod
@ -10,7 +10,7 @@ require (
|
||||
github.com/aws/aws-sdk-go v1.34.28
|
||||
github.com/beego/i18n v0.0.0-20140604031826-e87155e8f0c0
|
||||
github.com/bmatcuk/doublestar v1.1.1
|
||||
github.com/casbin/casbin v1.7.0
|
||||
github.com/casbin/casbin v1.9.1
|
||||
github.com/cenkalti/backoff/v4 v4.1.2
|
||||
github.com/coreos/go-oidc/v3 v3.0.0
|
||||
github.com/dghubble/sling v1.1.0
|
||||
@ -27,7 +27,7 @@ require (
|
||||
github.com/go-openapi/swag v0.19.14
|
||||
github.com/go-openapi/validate v0.19.10
|
||||
github.com/go-redis/redis/v8 v8.11.4
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
github.com/gocarina/gocsv v0.0.0-20210516172204-ca9e8a8ddea8
|
||||
github.com/gocraft/work v0.5.1
|
||||
github.com/golang-jwt/jwt/v4 v4.2.0
|
||||
@ -59,11 +59,11 @@ require (
|
||||
github.com/vmihailenco/msgpack/v5 v5.0.0-rc.2
|
||||
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.22.0
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.22.0
|
||||
go.opentelemetry.io/otel v1.3.0
|
||||
go.opentelemetry.io/otel v1.8.0
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.0.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.3.0
|
||||
go.opentelemetry.io/otel/sdk v1.3.0
|
||||
go.opentelemetry.io/otel/trace v1.3.0
|
||||
go.opentelemetry.io/otel/sdk v1.8.0
|
||||
go.opentelemetry.io/otel/trace v1.8.0
|
||||
go.uber.org/ratelimit v0.2.0
|
||||
golang.org/x/crypto v0.1.0
|
||||
golang.org/x/net v0.1.0
|
||||
@ -78,7 +78,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/beego/beego v1.12.11
|
||||
github.com/beego/beego/v2 v2.0.6
|
||||
golang.org/x/text v0.4.0
|
||||
)
|
||||
|
||||
@ -165,7 +165,7 @@ require (
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.1 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/moby/locker v1.0.1 // indirect
|
||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
|
||||
@ -182,7 +182,7 @@ require (
|
||||
github.com/prometheus/common v0.37.0 // indirect
|
||||
github.com/prometheus/procfs v0.8.0 // indirect
|
||||
github.com/satori/go.uuid v1.2.0 // indirect
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
|
||||
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
github.com/spf13/afero v1.6.0 // indirect
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
|
67
src/go.sum
67
src/go.sum
@ -83,7 +83,6 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
|
||||
github.com/ClickHouse/clickhouse-go v1.4.3/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI=
|
||||
github.com/FZambia/sentinel v1.1.0 h1:qrCBfxc8SvJihYNjBWgwUI93ZCvFe/PJIPTHKmlp8a8=
|
||||
github.com/FZambia/sentinel v1.1.0/go.mod h1:ytL1Am/RLlAoAXG6Kj5LNuw/TRRQrv2rt2FT26vP5gI=
|
||||
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
|
||||
@ -134,8 +133,6 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:CgnQgUtFrFz9mxFNtED3jI5tLDjKlOM+oUF/sTk6ps0=
|
||||
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
|
||||
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190726115642-cd293c93fd97 h1:bNE5ID4C3YOkROfvBjXJUG53gyb+8az3TQN02LqnGBk=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190726115642-cd293c93fd97/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ=
|
||||
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
|
||||
@ -190,12 +187,10 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.7.2/go.mod h1:8EzeIqfWt2wWT4rJVu3f21
|
||||
github.com/aws/smithy-go v1.7.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
|
||||
github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
|
||||
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc=
|
||||
github.com/beego/beego v1.12.11 h1:MWKcnpavb7iAIS0m6uuEq6pHKkYvGNw/5umIUKqL7jM=
|
||||
github.com/beego/beego v1.12.11/go.mod h1:QURFL1HldOcCZAxnc1cZ7wrplsYR5dKPHFjmk6WkLAs=
|
||||
github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
|
||||
github.com/beego/beego/v2 v2.0.6 h1:21Aqz3+RzUE1yP9a5xdU6LK54n9Z7NLEJtR4PE7NrPQ=
|
||||
github.com/beego/beego/v2 v2.0.6/go.mod h1:CH2/JIaB4ceGYVQlYqTAFft4pVk/ol1ZkakUrUvAyns=
|
||||
github.com/beego/i18n v0.0.0-20140604031826-e87155e8f0c0 h1:fQaDnUQvBXHHQdGBu9hz8nPznB4BeiPQokvmQVjmNEw=
|
||||
github.com/beego/i18n v0.0.0-20140604031826-e87155e8f0c0/go.mod h1:KLeFCpAMq2+50NkXC8iiJxLLiiTfTqrGtKEVm+2fk7s=
|
||||
github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
@ -211,15 +206,14 @@ github.com/bmatcuk/doublestar v1.1.1 h1:YroD6BJCZBYx06yYFEWvUuKVWQn3vLLQAVmDmvTS
|
||||
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
|
||||
github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70=
|
||||
github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
|
||||
github.com/bugsnag/bugsnag-go v1.5.2 h1:fdaGJJEReigPzSE6HajOhpJwE2IEP/TdHDHXKGeOJtc=
|
||||
github.com/bugsnag/bugsnag-go v1.5.2/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
|
||||
github.com/bugsnag/panicwrap v1.2.0 h1:OzrKrRvXis8qEvOkfcxNcYbOd2O7xXS2nnKMEMABFQA=
|
||||
github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
|
||||
github.com/casbin/casbin v1.7.0 h1:PuzlE8w0JBg/DhIqnkF1Dewf3z+qmUZMVN07PonvVUQ=
|
||||
github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
|
||||
github.com/casbin/casbin v1.9.1 h1:ucjbS5zTrmSLtH4XogqOG920Poe6QatdXtz1FEbApeM=
|
||||
github.com/casbin/casbin v1.9.1/go.mod h1:z8uPsfBJGUsnkagrt3G8QvjgTKFMBJ32UP8HpZllfog=
|
||||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
@ -362,9 +356,6 @@ github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+
|
||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/couchbase/go-couchbase v0.0.0-20201216133707-c04035124b17/go.mod h1:+/bddYDxXsf9qt0xpDUtRR47A2GjaXmGGAqQ/k3GJ8A=
|
||||
github.com/couchbase/gomemcached v0.1.2-0.20201224031647-c432ccf49f32/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo=
|
||||
github.com/couchbase/goutils v0.0.0-20210118111533-e33d3ffb5401/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
@ -372,7 +363,6 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
|
||||
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
|
||||
github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4=
|
||||
github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI=
|
||||
github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
|
||||
@ -432,9 +422,7 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw=
|
||||
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
@ -475,7 +463,6 @@ github.com/gabriel-vasile/mimetype v1.4.0/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmx
|
||||
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/glendc/gopher-json v0.0.0-20170414221815-dc4743023d0c/go.mod h1:Gja1A+xZ9BoviGJNA2E9vFkPjjsl+CoJxSXiQM1UXtw=
|
||||
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.1 h1:pDbRAunXzIUXfx4CB2QJFv5IuPiuoW+sWvr/Us009o8=
|
||||
@ -578,13 +565,13 @@ github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2K
|
||||
github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo=
|
||||
github.com/go-openapi/validate v0.19.10 h1:tG3SZ5DC5KF4cyt7nqLVcQXGj5A7mpaYkAcNPlDK+Yk=
|
||||
github.com/go-openapi/validate v0.19.10/go.mod h1:RKEZTUWDkxKQxN2jDT7ZnZi2bhZlbNMAuKvKB+IaGx8=
|
||||
github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-redis/redis/v8 v8.11.4 h1:kHoYkfZP6+pe04aFTnhDH6GDROa5yJdHJVNxV3F46Tg=
|
||||
github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
@ -949,7 +936,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4=
|
||||
github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
@ -996,8 +982,7 @@ github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vq
|
||||
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mattn/go-sqlite3 v1.14.7 h1:fxWBnXkxfM6sRiuH3bqJ4CfzZojMOLVc0UTsTglEghA=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||
@ -1018,8 +1003,9 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F
|
||||
github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
|
||||
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
|
||||
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
|
||||
@ -1136,7 +1122,6 @@ github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh
|
||||
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo=
|
||||
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
|
||||
@ -1146,7 +1131,6 @@ github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko
|
||||
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
||||
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
|
||||
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
||||
github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
|
||||
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI=
|
||||
github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY=
|
||||
github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
|
||||
@ -1172,7 +1156,6 @@ github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDf
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
|
||||
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
|
||||
github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
||||
@ -1238,16 +1221,13 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
|
||||
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 h1:DAYUYH5869yV94zvCES9F51oYtN5oGlwjxJJz7ZCnik=
|
||||
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
|
||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
|
||||
github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
|
||||
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
|
||||
github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
|
||||
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
@ -1292,7 +1272,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
|
||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
||||
github.com/spf13/viper v1.8.1 h1:Kq1fyeebqsBfbjZj4EL7gj2IO0mMaiyjYUWcUsl2O44=
|
||||
github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns=
|
||||
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
|
||||
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8=
|
||||
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
|
||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
@ -1319,7 +1298,6 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69
|
||||
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||
github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
|
||||
github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go v1.0.62 h1:Vnr3IqaafEuQUciG6D6EaeLJm26Mg8sjAfbI4OoeauM=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go v1.0.62/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
|
||||
@ -1329,7 +1307,6 @@ github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
|
||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||
github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
@ -1345,7 +1322,6 @@ github.com/vmihailenco/msgpack/v5 v5.0.0-rc.2 h1:ognci8XPlosGhIHK1OLYSpSpnlhSFeB
|
||||
github.com/vmihailenco/msgpack/v5 v5.0.0-rc.2/go.mod h1:HVxBVPUK/+fZMonk4bi1islLa8V3cfnBug0+4dykPzo=
|
||||
github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc=
|
||||
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||
github.com/wendal/errors v0.0.0-20181209125328-7f31f4b264ec/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
|
||||
github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||
github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI=
|
||||
github.com/xanzy/go-gitlab v0.15.0/go.mod h1:8zdQa/ri1dfn8eS3Ir1SyfvOKlw7WBJ8DVThkpGiXrs=
|
||||
@ -1371,7 +1347,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
|
||||
github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43 h1:+lm10QQTNSBd8DVTNGHx7o/IKu9HYDvLMffDhbyLccI=
|
||||
github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50 h1:hlE8//ciYMztlGpl/VA+Zm1AcTPHYkHJPbHqE6WJUXE=
|
||||
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f h1:ERexzlUfuTvpE74urLSbIQW0Z/6hF9t8U4NsJLaioAY=
|
||||
@ -1411,8 +1386,9 @@ go.opentelemetry.io/contrib/propagators v0.22.0/go.mod h1:xGOuXr6lLIF9BXipA4pm6U
|
||||
go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I=
|
||||
go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM=
|
||||
go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg=
|
||||
go.opentelemetry.io/otel v1.3.0 h1:APxLf0eiBwLl+SOXiJJCVYzA1OOJNyAoV8C5RNRyy7Y=
|
||||
go.opentelemetry.io/otel v1.3.0/go.mod h1:PWIKzi6JCp7sM0k9yZ43VX+T345uNbAkDKwHVjb2PTs=
|
||||
go.opentelemetry.io/otel v1.8.0 h1:zcvBFizPbpa1q7FehvFiHbQwGzmPILebO0tyqIR5Djg=
|
||||
go.opentelemetry.io/otel v1.8.0/go.mod h1:2pkj+iMj0o03Y+cW6/m8Y4WkRdYN3AvCXCnzRMp9yvM=
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.0.0 h1:cLhx8llHw02h5JTqGqaRbYn+QVKHmrzD9vEbKnSPk5U=
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.0.0/go.mod h1:q10N1AolE1JjqKrFJK2tYw0iZpmX+HBaXBtuCzRnBGQ=
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0 h1:R/OBkMoGgfy2fLhs2QhkCI1w4HLEQX92GCcJB6SSdNk=
|
||||
@ -1429,13 +1405,15 @@ go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1G
|
||||
go.opentelemetry.io/otel/oteltest v1.0.0-RC2 h1:xNKqMhlZYkASSyvF4JwObZFMq0jhFN3c3SP+2rCzVPk=
|
||||
go.opentelemetry.io/otel/oteltest v1.0.0-RC2/go.mod h1:kiQ4tw5tAL4JLTbcOYwK1CWI1HkT5aiLzHovgOVnz/A=
|
||||
go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM=
|
||||
go.opentelemetry.io/otel/sdk v1.3.0 h1:3278edCoH89MEJ0Ky8WQXVmDQv3FX4ZJ3Pp+9fJreAI=
|
||||
go.opentelemetry.io/otel/sdk v1.3.0/go.mod h1:rIo4suHNhQwBIPg9axF8V9CA72Wz2mKF1teNrup8yzs=
|
||||
go.opentelemetry.io/otel/sdk v1.8.0 h1:xwu69/fNuwbSHWe/0PGS888RmjWY181OmcXDQKu7ZQk=
|
||||
go.opentelemetry.io/otel/sdk v1.8.0/go.mod h1:uPSfc+yfDH2StDM/Rm35WE8gXSNdvCg023J6HeGNO0c=
|
||||
go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg=
|
||||
go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4=
|
||||
go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs=
|
||||
go.opentelemetry.io/otel/trace v1.3.0 h1:doy8Hzb1RJ+I3yFhtDmwNc7tIyw1tNMOIsyPzp1NOGY=
|
||||
go.opentelemetry.io/otel/trace v1.3.0/go.mod h1:c/VDhno8888bvQYmbYLqe41/Ldmr/KKunbvWM4/fEjk=
|
||||
go.opentelemetry.io/otel/trace v1.8.0 h1:cSy0DF9eGI5WIfNwZ1q2iUyGj00tGzP24dE1lOlHrfY=
|
||||
go.opentelemetry.io/otel/trace v1.8.0/go.mod h1:0Bt3PXY8w+3pheS3hQUt+wow8b1ojPaTBoTCh2zIFI4=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU=
|
||||
go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ=
|
||||
@ -1483,7 +1461,6 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
@ -1934,14 +1911,18 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/dancannon/gorethink.v3 v3.0.5 h1:/g7PWP7zUS6vSNmHSDbjCHQh1Rqn8Jy6zSMQxAsBSMQ=
|
||||
gopkg.in/dancannon/gorethink.v3 v3.0.5/go.mod h1:GXsi1e3N2OcKhcP6nsYABTiUejbWMFO4GY5a4pEaeEc=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fatih/pool.v2 v2.0.0 h1:xIFeWtxifuQJGk/IEPKsTduEKcKvPmhoiVDGpC40nKg=
|
||||
gopkg.in/fatih/pool.v2 v2.0.0/go.mod h1:8xVGeu1/2jr2wm5V9SPuMht2H5AEmf5aFMGSQixtjTY=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo=
|
||||
gopkg.in/gorethink/gorethink.v3 v3.0.5 h1:e2Uc/Xe+hpcVQFsj6MuHlYog3r0JYpnTzwDj/y2O4MU=
|
||||
gopkg.in/gorethink/gorethink.v3 v3.0.5/go.mod h1:+3yIIHJUGMBK+wyPH+iN5TP+88ikFDfZdqTlK3Y9q8I=
|
||||
gopkg.in/h2non/gentleman.v1 v1.0.4/go.mod h1:JYuHVdFzS4MKOXe0o+chKJ4hCe6tqKKw9XH9YP6WFrg=
|
||||
gopkg.in/h2non/gock.v1 v1.0.16 h1:F11k+OafeuFENsjei5t2vMTSTs9L62AdyTe4E1cgdG8=
|
||||
@ -1952,13 +1933,13 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
|
||||
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
gopkg.in/square/go-jose.v2 v2.5.1 h1:7odma5RETjNHWJnR32wx8t+Io4djHE1PqxCFx3iiZ2w=
|
||||
gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
@ -1981,8 +1962,10 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/postgres v1.0.8/go.mod h1:4eOzrI1MUfm6ObJU/UcmbXyiHSs8jSwH95G5P5dxcAg=
|
||||
gorm.io/gorm v1.20.12/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
|
||||
gorm.io/gorm v1.21.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
|
||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
|
||||
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
|
||||
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
|
||||
helm.sh/helm/v3 v3.10.1 h1:uTnNlYx8QcTSNA4ZJ50Llwife4CSohUY4ehumyVf2QE=
|
||||
helm.sh/helm/v3 v3.10.1/go.mod h1:CXOcs02AYvrlPMWARNYNRgf2rNP7gLJQsi/Ubd4EDrI=
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
o "github.com/beego/beego/orm"
|
||||
o "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/jobservice/config"
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
o "github.com/beego/beego/orm"
|
||||
o "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/jobservice/job"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
o "github.com/beego/beego/orm"
|
||||
o "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/jobservice/config"
|
||||
"github.com/goharbor/harbor/src/jobservice/env"
|
||||
|
@ -15,7 +15,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// HTTPAuthProxy wraps the settings for HTTP auth proxy
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
package orm
|
||||
|
||||
import "github.com/beego/beego/orm"
|
||||
import "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
var (
|
||||
// Crt is a global instance of ORM creator
|
||||
|
@ -15,7 +15,7 @@
|
||||
package orm
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/jackc/pgconn"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
|
@ -17,7 +17,7 @@ package orm
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"sync"
|
||||
"unicode"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
)
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
|
@ -16,15 +16,15 @@ package orm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
tracelib "github.com/goharbor/harbor/src/lib/trace"
|
||||
)
|
||||
@ -71,8 +71,8 @@ func init() {
|
||||
}
|
||||
|
||||
// FromContext returns orm from context
|
||||
func FromContext(ctx context.Context) (orm.Ormer, error) {
|
||||
o, ok := ctx.Value(ormKey{}).(orm.Ormer)
|
||||
func FromContext(ctx context.Context) (orm.QueryExecutor, error) {
|
||||
o, ok := ctx.Value(ormKey{}).(orm.QueryExecutor)
|
||||
if !ok {
|
||||
return nil, errors.New("cannot get the ORM from context")
|
||||
}
|
||||
@ -80,7 +80,7 @@ func FromContext(ctx context.Context) (orm.Ormer, error) {
|
||||
}
|
||||
|
||||
// NewContext returns new context with orm
|
||||
func NewContext(ctx context.Context, o orm.Ormer) context.Context {
|
||||
func NewContext(ctx context.Context, o orm.QueryExecutor) context.Context {
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
@ -105,7 +105,7 @@ func Copy(ctx context.Context) context.Context {
|
||||
|
||||
type operationNameKey struct{}
|
||||
|
||||
// SetTransactionOpName sets the transaction operation name
|
||||
// SetTransactionOpNameToContext sets the transaction operation name
|
||||
func SetTransactionOpNameToContext(ctx context.Context, name string) context.Context {
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
@ -136,13 +136,24 @@ func WithTransaction(f func(ctx context.Context) error) func(ctx context.Context
|
||||
return err
|
||||
}
|
||||
|
||||
tx := ormerTx{Ormer: o}
|
||||
var tx ormerTx
|
||||
if _, ok := o.(orm.Ormer); ok {
|
||||
tx = ormerTx{Ormer: o.(orm.Ormer)}
|
||||
} else if _, ok := o.(orm.TxOrmer); ok {
|
||||
tx = ormerTx{TxOrmer: o.(orm.TxOrmer)}
|
||||
} else {
|
||||
return errors.New("no orm found in the context")
|
||||
}
|
||||
|
||||
if err := tx.Begin(); err != nil {
|
||||
tracelib.RecordError(span, err, "begin transaction failed")
|
||||
log.Errorf("begin transaction failed: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// When set multiple times, context.WithValue returns only the last ormer.
|
||||
// To ensure that the rollback works, set TxOrmer as the ormer in the transaction.
|
||||
cx = NewContext(cx, tx.TxOrmer)
|
||||
if err := f(cx); err != nil {
|
||||
span.AddEvent("rollback transaction")
|
||||
if e := tx.Rollback(); e != nil {
|
||||
@ -164,7 +175,7 @@ func WithTransaction(f func(ctx context.Context) error) func(ctx context.Context
|
||||
}
|
||||
}
|
||||
|
||||
// ReadOrCreate read or create instance to datebase, retry to read when met a duplicate key error after the creating
|
||||
// ReadOrCreate read or create instance to database, retry to read when met a duplicate key error after the creating
|
||||
func ReadOrCreate(ctx context.Context, md interface{}, col1 string, cols ...string) (created bool, id int64, err error) {
|
||||
getter, ok := md.(interface {
|
||||
GetID() int64
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
)
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@ -37,6 +37,7 @@ func HasCommittedKey(ctx context.Context) bool {
|
||||
// ormerTx transaction which support savepoint
|
||||
type ormerTx struct {
|
||||
orm.Ormer
|
||||
orm.TxOrmer
|
||||
savepoint string
|
||||
}
|
||||
|
||||
@ -48,28 +49,30 @@ func (o *ormerTx) createSavepoint() error {
|
||||
val := uuid.New()
|
||||
o.savepoint = fmt.Sprintf("p%s", hex.EncodeToString(val[:]))
|
||||
|
||||
_, err := o.Raw(fmt.Sprintf("SAVEPOINT %s", o.savepoint)).Exec()
|
||||
_, err := o.TxOrmer.Raw(fmt.Sprintf("SAVEPOINT %s", o.savepoint)).Exec()
|
||||
return err
|
||||
}
|
||||
|
||||
func (o *ormerTx) releaseSavepoint() error {
|
||||
_, err := o.Raw(fmt.Sprintf("RELEASE SAVEPOINT %s", o.savepoint)).Exec()
|
||||
_, err := o.TxOrmer.Raw(fmt.Sprintf("RELEASE SAVEPOINT %s", o.savepoint)).Exec()
|
||||
return err
|
||||
}
|
||||
|
||||
func (o *ormerTx) rollbackToSavepoint() error {
|
||||
_, err := o.Raw(fmt.Sprintf("ROLLBACK TO SAVEPOINT %s", o.savepoint)).Exec()
|
||||
_, err := o.TxOrmer.Raw(fmt.Sprintf("ROLLBACK TO SAVEPOINT %s", o.savepoint)).Exec()
|
||||
return err
|
||||
}
|
||||
|
||||
func (o *ormerTx) Begin() error {
|
||||
err := o.Ormer.Begin()
|
||||
if err == orm.ErrTxHasBegan {
|
||||
// transaction has began for the ormer, so begin nested transaction by savepoint
|
||||
if o.TxOrmer != nil {
|
||||
return o.createSavepoint()
|
||||
}
|
||||
|
||||
return err
|
||||
txOrmer, err := o.Ormer.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.TxOrmer = txOrmer
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ormerTx) Commit() error {
|
||||
@ -77,7 +80,7 @@ func (o *ormerTx) Commit() error {
|
||||
return o.releaseSavepoint()
|
||||
}
|
||||
|
||||
return o.Ormer.Commit()
|
||||
return o.TxOrmer.Commit()
|
||||
}
|
||||
|
||||
func (o *ormerTx) Rollback() error {
|
||||
@ -85,5 +88,5 @@ func (o *ormerTx) Rollback() error {
|
||||
return o.rollbackToSavepoint()
|
||||
}
|
||||
|
||||
return o.Ormer.Rollback()
|
||||
return o.TxOrmer.Rollback()
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
beegorm "github.com/beego/beego/orm"
|
||||
beegorm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/golang-migrate/migrate/v4"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
common_dao "github.com/goharbor/harbor/src/common/dao"
|
||||
|
@ -17,7 +17,7 @@ package dao
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
|
@ -17,7 +17,7 @@ package dao
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
beegorm "github.com/beego/beego/orm"
|
||||
beegorm "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/rbac"
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
@ -90,7 +90,7 @@ func (*dao) Purge(ctx context.Context, retentionHour int, includeOperations []st
|
||||
return delRows, err
|
||||
}
|
||||
|
||||
func dryRunPurge(ormer beegorm.Ormer, retentionHour int, includeOperations []string) (int64, error) {
|
||||
func dryRunPurge(ormer beegorm.QueryExecutor, retentionHour int, includeOperations []string) (int64, error) {
|
||||
sql := "SELECT count(1) cnt FROM audit_log WHERE op_time < NOW() - ? * interval '1 hour' "
|
||||
filterOps := permitOps(includeOperations)
|
||||
if len(filterOps) == 0 {
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
common_dao "github.com/goharbor/harbor/src/common/dao"
|
||||
|
@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
"time"
|
||||
|
||||
beego_orm "github.com/beego/beego/orm"
|
||||
beego_orm "github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/docker/distribution/manifest/manifestlist"
|
||||
"github.com/docker/distribution/manifest/schema1"
|
||||
"github.com/docker/distribution/manifest/schema2"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/validation"
|
||||
"github.com/beego/beego/v2/core/validation"
|
||||
)
|
||||
|
||||
// Metadata of the immutable rule
|
||||
|
@ -3,7 +3,7 @@ package models
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
|
@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
|
@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -4,8 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
beego_orm "github.com/beego/beego/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
"github.com/goharbor/harbor/src/pkg/p2p/preheat/models/provider"
|
||||
@ -40,8 +38,7 @@ var _ DAO = (*dao)(nil)
|
||||
|
||||
// Create adds a new distribution instance.
|
||||
func (d *dao) Create(ctx context.Context, instance *provider.Instance) (id int64, err error) {
|
||||
var o beego_orm.Ormer
|
||||
o, err = orm.FromContext(ctx)
|
||||
o, err := orm.FromContext(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
beego_orm "github.com/beego/beego/orm"
|
||||
beego_orm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
|
@ -17,7 +17,7 @@ package policy
|
||||
import (
|
||||
"context"
|
||||
|
||||
beego_orm "github.com/beego/beego/orm"
|
||||
beego_orm "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
@ -62,8 +62,7 @@ func (d *dao) Count(ctx context.Context, query *q.Query) (total int64, err error
|
||||
|
||||
// Create a policy schema.
|
||||
func (d *dao) Create(ctx context.Context, schema *policy.Schema) (id int64, err error) {
|
||||
var ormer beego_orm.Ormer
|
||||
ormer, err = orm.FromContext(ctx)
|
||||
ormer, err := orm.FromContext(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -81,8 +80,7 @@ func (d *dao) Create(ctx context.Context, schema *policy.Schema) (id int64, err
|
||||
|
||||
// Update a policy schema.
|
||||
func (d *dao) Update(ctx context.Context, schema *policy.Schema, props ...string) (err error) {
|
||||
var ormer beego_orm.Ormer
|
||||
ormer, err = orm.FromContext(ctx)
|
||||
ormer, err := orm.FromContext(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -101,8 +99,7 @@ func (d *dao) Update(ctx context.Context, schema *policy.Schema, props ...string
|
||||
|
||||
// Get a policy schema by id.
|
||||
func (d *dao) Get(ctx context.Context, id int64) (schema *policy.Schema, err error) {
|
||||
var ormer beego_orm.Ormer
|
||||
ormer, err = orm.FromContext(ctx)
|
||||
ormer, err := orm.FromContext(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -120,8 +117,7 @@ func (d *dao) Get(ctx context.Context, id int64) (schema *policy.Schema, err err
|
||||
|
||||
// GetByName gets a policy schema by name.
|
||||
func (d *dao) GetByName(ctx context.Context, projectID int64, name string) (schema *policy.Schema, err error) {
|
||||
var ormer beego_orm.Ormer
|
||||
ormer, err = orm.FromContext(ctx)
|
||||
ormer, err := orm.FromContext(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -139,8 +135,7 @@ func (d *dao) GetByName(ctx context.Context, projectID int64, name string) (sche
|
||||
|
||||
// Delete a policy schema by id.
|
||||
func (d *dao) Delete(ctx context.Context, id int64) (err error) {
|
||||
var ormer beego_orm.Ormer
|
||||
ormer, err = orm.FromContext(ctx)
|
||||
ormer, err := orm.FromContext(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
beego_orm "github.com/beego/beego/orm"
|
||||
beego_orm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
common_dao "github.com/goharbor/harbor/src/common/dao"
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
beego_orm "github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/validation"
|
||||
beego_orm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/validation"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/utils"
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
|
@ -17,7 +17,7 @@ package policy
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego/validation"
|
||||
"github.com/beego/beego/v2/core/validation"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ package provider
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ package models
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -17,7 +17,7 @@ package dao
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
common_dao "github.com/goharbor/harbor/src/common/dao"
|
||||
|
@ -17,7 +17,7 @@ package dao
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
common_dao "github.com/goharbor/harbor/src/common/dao"
|
||||
|
@ -17,7 +17,7 @@ package model
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
o "github.com/beego/beego/orm"
|
||||
o "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
|
@ -3,7 +3,7 @@ package models
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// const definitions
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/pkg/retention/dao"
|
||||
"github.com/goharbor/harbor/src/pkg/retention/dao/models"
|
||||
|
@ -15,7 +15,7 @@
|
||||
package policy
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/validation"
|
||||
"github.com/beego/beego/v2/core/validation"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/selector/selectors/doublestar"
|
||||
"github.com/goharbor/harbor/src/pkg/retention/policy/rule"
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego/validation"
|
||||
"github.com/beego/beego/v2/core/validation"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/goharbor/harbor/src/pkg/retention/policy/rule"
|
||||
|
@ -15,7 +15,7 @@
|
||||
package rule
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/validation"
|
||||
"github.com/beego/beego/v2/core/validation"
|
||||
)
|
||||
|
||||
// Metadata of the retention rule
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
beego_orm "github.com/beego/beego/orm"
|
||||
beego_orm "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
q2 "github.com/goharbor/harbor/src/lib/q"
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
|
@ -17,7 +17,7 @@ package dao
|
||||
import (
|
||||
"context"
|
||||
|
||||
beego_orm "github.com/beego/beego/orm"
|
||||
beego_orm "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
beegoorm "github.com/beego/beego/orm"
|
||||
beegoorm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
common_dao "github.com/goharbor/harbor/src/common/dao"
|
||||
|
@ -17,7 +17,7 @@ package dao
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
beego_orm "github.com/beego/beego/orm"
|
||||
beego_orm "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/goharbor/harbor/src/controller/blob"
|
||||
|
@ -17,7 +17,7 @@ package orm
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
o "github.com/beego/beego/orm"
|
||||
o "github.com/beego/beego/v2/client/orm"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
"github.com/goharbor/harbor/src/server/middleware"
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
o "github.com/beego/beego/orm"
|
||||
o "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
||||
"github.com/beego/beego"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/common/security"
|
||||
@ -30,12 +30,12 @@ type session struct{}
|
||||
|
||||
func (s *session) Generate(req *http.Request) security.Context {
|
||||
log := log.G(req.Context())
|
||||
store, err := beego.GlobalSessions.SessionStart(httptest.NewRecorder(), req)
|
||||
store, err := web.GlobalSessions.SessionStart(httptest.NewRecorder(), req)
|
||||
if err != nil {
|
||||
log.Errorf("failed to get the session store for request: %v", err)
|
||||
return nil
|
||||
}
|
||||
userInterface := store.Get("user")
|
||||
userInterface := store.Get(req.Context(), "user")
|
||||
if userInterface == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego"
|
||||
beegosession "github.com/beego/beego/session"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
beegosession "github.com/beego/beego/v2/server/web/session"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@ -32,15 +32,15 @@ func TestSession(t *testing.T) {
|
||||
var err error
|
||||
// initialize beego session manager
|
||||
conf := &beegosession.ManagerConfig{
|
||||
CookieName: beego.BConfig.WebConfig.Session.SessionName,
|
||||
Gclifetime: beego.BConfig.WebConfig.Session.SessionGCMaxLifetime,
|
||||
ProviderConfig: filepath.ToSlash(beego.BConfig.WebConfig.Session.SessionProviderConfig),
|
||||
Secure: beego.BConfig.Listen.EnableHTTPS,
|
||||
EnableSetCookie: beego.BConfig.WebConfig.Session.SessionAutoSetCookie,
|
||||
Domain: beego.BConfig.WebConfig.Session.SessionDomain,
|
||||
CookieLifeTime: beego.BConfig.WebConfig.Session.SessionCookieLifeTime,
|
||||
CookieName: web.BConfig.WebConfig.Session.SessionName,
|
||||
Gclifetime: web.BConfig.WebConfig.Session.SessionGCMaxLifetime,
|
||||
ProviderConfig: filepath.ToSlash(web.BConfig.WebConfig.Session.SessionProviderConfig),
|
||||
Secure: web.BConfig.Listen.EnableHTTPS,
|
||||
EnableSetCookie: web.BConfig.WebConfig.Session.SessionAutoSetCookie,
|
||||
Domain: web.BConfig.WebConfig.Session.SessionDomain,
|
||||
CookieLifeTime: web.BConfig.WebConfig.Session.SessionCookieLifeTime,
|
||||
}
|
||||
beego.GlobalSessions, err = beegosession.NewManager("memory", conf)
|
||||
web.GlobalSessions, err = beegosession.NewManager("memory", conf)
|
||||
require.Nil(t, err)
|
||||
|
||||
user := models.User{
|
||||
@ -51,9 +51,9 @@ func TestSession(t *testing.T) {
|
||||
}
|
||||
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1/api/projects/", nil)
|
||||
require.Nil(t, err)
|
||||
store, err := beego.GlobalSessions.SessionStart(httptest.NewRecorder(), req)
|
||||
store, err := web.GlobalSessions.SessionStart(httptest.NewRecorder(), req)
|
||||
require.Nil(t, err)
|
||||
err = store.Set("user", user)
|
||||
err = store.Set(req.Context(), "user", user)
|
||||
require.Nil(t, err)
|
||||
|
||||
session := &session{}
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego"
|
||||
beegosession "github.com/beego/beego/session"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
beegosession "github.com/beego/beego/v2/server/web/session"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@ -41,19 +41,19 @@ func TestSession(t *testing.T) {
|
||||
assert.False(t, carrySession)
|
||||
|
||||
// contains session
|
||||
beego.BConfig.WebConfig.Session.SessionName = config.SessionCookieName
|
||||
web.BConfig.WebConfig.Session.SessionName = config.SessionCookieName
|
||||
conf := &beegosession.ManagerConfig{
|
||||
CookieName: beego.BConfig.WebConfig.Session.SessionName,
|
||||
Gclifetime: beego.BConfig.WebConfig.Session.SessionGCMaxLifetime,
|
||||
ProviderConfig: filepath.ToSlash(beego.BConfig.WebConfig.Session.SessionProviderConfig),
|
||||
Secure: beego.BConfig.Listen.EnableHTTPS,
|
||||
EnableSetCookie: beego.BConfig.WebConfig.Session.SessionAutoSetCookie,
|
||||
Domain: beego.BConfig.WebConfig.Session.SessionDomain,
|
||||
CookieLifeTime: beego.BConfig.WebConfig.Session.SessionCookieLifeTime,
|
||||
CookieName: web.BConfig.WebConfig.Session.SessionName,
|
||||
Gclifetime: web.BConfig.WebConfig.Session.SessionGCMaxLifetime,
|
||||
ProviderConfig: filepath.ToSlash(web.BConfig.WebConfig.Session.SessionProviderConfig),
|
||||
Secure: web.BConfig.Listen.EnableHTTPS,
|
||||
EnableSetCookie: web.BConfig.WebConfig.Session.SessionAutoSetCookie,
|
||||
Domain: web.BConfig.WebConfig.Session.SessionDomain,
|
||||
CookieLifeTime: web.BConfig.WebConfig.Session.SessionCookieLifeTime,
|
||||
}
|
||||
beego.GlobalSessions, err = beegosession.NewManager("memory", conf)
|
||||
web.GlobalSessions, err = beegosession.NewManager("memory", conf)
|
||||
require.Nil(t, err)
|
||||
_, err = beego.GlobalSessions.SessionStart(httptest.NewRecorder(), req)
|
||||
_, err = web.GlobalSessions.SessionStart(httptest.NewRecorder(), req)
|
||||
require.Nil(t, err)
|
||||
Middleware()(handler).ServeHTTP(nil, req)
|
||||
assert.True(t, carrySession)
|
||||
|
@ -16,61 +16,70 @@ package transaction
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
o "github.com/beego/beego/orm"
|
||||
o "github.com/beego/beego/v2/client/orm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
"github.com/goharbor/harbor/src/server/middleware"
|
||||
)
|
||||
|
||||
type mockOrmer struct {
|
||||
o.Ormer
|
||||
records []interface{}
|
||||
beginErr error
|
||||
commitErr error
|
||||
tx mockTxOrmer
|
||||
beginErr error
|
||||
}
|
||||
|
||||
func (m *mockOrmer) Insert(i interface{}) (int64, error) {
|
||||
m.records = append(m.records, i)
|
||||
|
||||
return int64(len(m.records)), nil
|
||||
}
|
||||
|
||||
func (m *mockOrmer) Begin() error {
|
||||
return m.beginErr
|
||||
}
|
||||
|
||||
func (m *mockOrmer) Commit() error {
|
||||
return m.commitErr
|
||||
}
|
||||
|
||||
func (m *mockOrmer) Rollback() error {
|
||||
m.ResetRecords()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockOrmer) ResetRecords() {
|
||||
m.records = nil
|
||||
func (m *mockOrmer) Begin() (o.TxOrmer, error) {
|
||||
return &m.tx, m.beginErr
|
||||
}
|
||||
|
||||
func (m *mockOrmer) Reset() {
|
||||
m.ResetRecords()
|
||||
|
||||
m.tx.Reset()
|
||||
m.beginErr = nil
|
||||
}
|
||||
|
||||
type mockTxOrmer struct {
|
||||
o.TxOrmer
|
||||
commitErr error
|
||||
records []interface{}
|
||||
}
|
||||
|
||||
func (m *mockTxOrmer) Insert(i interface{}) (int64, error) {
|
||||
m.records = append(m.records, i)
|
||||
return int64(len(m.records)), nil
|
||||
}
|
||||
|
||||
func (m *mockTxOrmer) Commit() error {
|
||||
return m.commitErr
|
||||
}
|
||||
|
||||
func (m *mockTxOrmer) Rollback() error {
|
||||
m.ResetRecords()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockTxOrmer) ResetRecords() {
|
||||
m.records = nil
|
||||
}
|
||||
|
||||
func (m *mockTxOrmer) Reset() {
|
||||
m.ResetRecords()
|
||||
m.commitErr = nil
|
||||
}
|
||||
|
||||
func TestTransaction(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
mo := &mockOrmer{}
|
||||
tx := mockTxOrmer{}
|
||||
mo := &mockOrmer{
|
||||
tx: tx,
|
||||
}
|
||||
|
||||
newRequest := func(method, target string, body io.Reader) *http.Request {
|
||||
req := httptest.NewRequest(http.MethodGet, "/req1", nil)
|
||||
@ -79,7 +88,7 @@ func TestTransaction(t *testing.T) {
|
||||
|
||||
next := func(status int) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
mo.Insert("record1")
|
||||
mo.tx.Insert("record1")
|
||||
w.WriteHeader(status)
|
||||
})
|
||||
}
|
||||
@ -89,17 +98,17 @@ func TestTransaction(t *testing.T) {
|
||||
rec1 := httptest.NewRecorder()
|
||||
Middleware()(next(http.StatusOK)).ServeHTTP(rec1, req1)
|
||||
assert.Equal(http.StatusOK, rec1.Code)
|
||||
assert.NotEmpty(mo.records)
|
||||
assert.NotEmpty(mo.tx.records)
|
||||
|
||||
mo.ResetRecords()
|
||||
assert.Empty(mo.records)
|
||||
mo.tx.ResetRecords()
|
||||
assert.Empty(mo.tx.records)
|
||||
|
||||
// test response status code not accepted
|
||||
req2 := newRequest(http.MethodGet, "/req", nil)
|
||||
rec2 := httptest.NewRecorder()
|
||||
Middleware()(next(http.StatusBadRequest)).ServeHTTP(rec2, req2)
|
||||
assert.Equal(http.StatusBadRequest, rec2.Code)
|
||||
assert.Empty(mo.records)
|
||||
assert.Empty(mo.tx.records)
|
||||
|
||||
// test begin transaction failed
|
||||
mo.beginErr = errors.New("begin tx failed")
|
||||
@ -107,11 +116,11 @@ func TestTransaction(t *testing.T) {
|
||||
rec3 := httptest.NewRecorder()
|
||||
Middleware()(next(http.StatusBadRequest)).ServeHTTP(rec3, req3)
|
||||
assert.Equal(http.StatusInternalServerError, rec3.Code)
|
||||
assert.Empty(mo.records)
|
||||
assert.Empty(mo.tx.records)
|
||||
|
||||
// test commit transaction failed
|
||||
mo.beginErr = nil
|
||||
mo.commitErr = errors.New("commit tx failed")
|
||||
mo.tx.commitErr = errors.New("commit tx failed")
|
||||
req4 := newRequest(http.MethodGet, "/req", nil)
|
||||
rec4 := httptest.NewRecorder()
|
||||
Middleware()(next(http.StatusOK)).ServeHTTP(rec4, req4)
|
||||
@ -119,12 +128,12 @@ func TestTransaction(t *testing.T) {
|
||||
|
||||
// test MustCommit
|
||||
mo.Reset()
|
||||
assert.Empty(mo.records)
|
||||
assert.Empty(mo.tx.records)
|
||||
|
||||
txMustCommit := func(status int) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
defer MustCommit(r)
|
||||
mo.Insert("record1")
|
||||
mo.tx.Insert("record1")
|
||||
w.WriteHeader(status)
|
||||
})
|
||||
}
|
||||
@ -139,7 +148,7 @@ func TestTransaction(t *testing.T) {
|
||||
|
||||
Middleware()(m1((txMustCommit(http.StatusBadRequest)))).ServeHTTP(rec5, req5)
|
||||
assert.Equal(http.StatusBadRequest, rec2.Code)
|
||||
assert.NotEmpty(mo.records)
|
||||
assert.NotEmpty(mo.tx.records)
|
||||
}
|
||||
|
||||
func TestMustCommit(t *testing.T) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user