mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 02:05:41 +01:00
feat: add ORM_DEBUG env option (#14709)
Signed-off-by: Moshe Immerman <moshe@flanksource.com>
This commit is contained in:
parent
bd9a1c6722
commit
d1b553fd3a
@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -47,6 +48,12 @@ func RegisterModel(models ...interface{}) {
|
||||
|
||||
type ormKey struct{}
|
||||
|
||||
func init() {
|
||||
if os.Getenv("ORM_DEBUG") == "true" {
|
||||
orm.Debug = true
|
||||
}
|
||||
}
|
||||
|
||||
// FromContext returns orm from context
|
||||
func FromContext(ctx context.Context) (orm.Ormer, error) {
|
||||
o, ok := ctx.Value(ormKey{}).(orm.Ormer)
|
||||
|
Loading…
Reference in New Issue
Block a user