This reverts commit 326ea86a57.
This commit is contained in:
@@ -153,6 +153,9 @@ var (
|
||||
LDAPAllowSignup bool
|
||||
LDAPActiveSyncEnabled bool
|
||||
|
||||
// Quota
|
||||
Quota QuotaSettings
|
||||
|
||||
// Alerting
|
||||
AlertingEnabled *bool
|
||||
ExecuteAlerts bool
|
||||
@@ -419,12 +422,12 @@ type Cfg struct {
|
||||
LDAPSkipOrgRoleSync bool
|
||||
LDAPAllowSignup bool
|
||||
|
||||
Quota QuotaSettings
|
||||
|
||||
DefaultTheme string
|
||||
DefaultLocale string
|
||||
HomePage string
|
||||
|
||||
Quota QuotaSettings
|
||||
|
||||
AutoAssignOrg bool
|
||||
AutoAssignOrgId int
|
||||
AutoAssignOrgRole string
|
||||
@@ -1050,12 +1053,11 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
|
||||
cfg.readAzureSettings()
|
||||
cfg.readSessionConfig()
|
||||
cfg.readSmtpSettings()
|
||||
cfg.readQuotaSettings()
|
||||
if err := cfg.readAnnotationSettings(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cfg.readQuotaSettings()
|
||||
|
||||
cfg.readExpressionsSettings()
|
||||
if err := cfg.readGrafanaEnvironmentMetrics(); err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type OrgQuota struct {
|
||||
User int64 `target:"org_user"`
|
||||
DataSource int64 `target:"data_source"`
|
||||
@@ -23,17 +27,45 @@ type GlobalQuota struct {
|
||||
File int64 `target:"file"`
|
||||
}
|
||||
|
||||
func (q *OrgQuota) ToMap() map[string]int64 {
|
||||
return quotaToMap(*q)
|
||||
}
|
||||
|
||||
func (q *UserQuota) ToMap() map[string]int64 {
|
||||
return quotaToMap(*q)
|
||||
}
|
||||
|
||||
func quotaToMap(q interface{}) map[string]int64 {
|
||||
qMap := make(map[string]int64)
|
||||
typ := reflect.TypeOf(q)
|
||||
val := reflect.ValueOf(q)
|
||||
|
||||
for i := 0; i < typ.NumField(); i++ {
|
||||
field := typ.Field(i)
|
||||
name := field.Tag.Get("target")
|
||||
if name == "" {
|
||||
name = field.Name
|
||||
}
|
||||
if name == "-" {
|
||||
continue
|
||||
}
|
||||
value := val.Field(i)
|
||||
qMap[name] = value.Int()
|
||||
}
|
||||
return qMap
|
||||
}
|
||||
|
||||
type QuotaSettings struct {
|
||||
Enabled bool
|
||||
Org OrgQuota
|
||||
User UserQuota
|
||||
Global GlobalQuota
|
||||
Org *OrgQuota
|
||||
User *UserQuota
|
||||
Global *GlobalQuota
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readQuotaSettings() {
|
||||
// set global defaults.
|
||||
quota := cfg.Raw.Section("quota")
|
||||
cfg.Quota.Enabled = quota.Key("enabled").MustBool(false)
|
||||
Quota.Enabled = quota.Key("enabled").MustBool(false)
|
||||
|
||||
var alertOrgQuota int64
|
||||
var alertGlobalQuota int64
|
||||
@@ -42,7 +74,7 @@ func (cfg *Cfg) readQuotaSettings() {
|
||||
alertGlobalQuota = quota.Key("global_alert_rule").MustInt64(-1)
|
||||
}
|
||||
// per ORG Limits
|
||||
cfg.Quota.Org = OrgQuota{
|
||||
Quota.Org = &OrgQuota{
|
||||
User: quota.Key("org_user").MustInt64(10),
|
||||
DataSource: quota.Key("org_data_source").MustInt64(10),
|
||||
Dashboard: quota.Key("org_dashboard").MustInt64(10),
|
||||
@@ -51,12 +83,12 @@ func (cfg *Cfg) readQuotaSettings() {
|
||||
}
|
||||
|
||||
// per User limits
|
||||
cfg.Quota.User = UserQuota{
|
||||
Quota.User = &UserQuota{
|
||||
Org: quota.Key("user_org").MustInt64(10),
|
||||
}
|
||||
|
||||
// Global Limits
|
||||
cfg.Quota.Global = GlobalQuota{
|
||||
Quota.Global = &GlobalQuota{
|
||||
User: quota.Key("global_user").MustInt64(-1),
|
||||
Org: quota.Key("global_org").MustInt64(-1),
|
||||
DataSource: quota.Key("global_data_source").MustInt64(-1),
|
||||
@@ -66,4 +98,6 @@ func (cfg *Cfg) readQuotaSettings() {
|
||||
File: quota.Key("global_file").MustInt64(-1),
|
||||
AlertRule: alertGlobalQuota,
|
||||
}
|
||||
|
||||
cfg.Quota = Quota
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user