refactoring: enterprise build/hooks refactorings (#12478)
This commit is contained in:
@@ -13,6 +13,7 @@ type IndexViewData struct {
|
||||
Theme string
|
||||
NewGrafanaVersionExists bool
|
||||
NewGrafanaVersion string
|
||||
AppName string
|
||||
}
|
||||
|
||||
type PluginCss struct {
|
||||
|
||||
@@ -132,7 +132,6 @@ func getFrontendSettingsMap(c *m.ReqContext) (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
jsonObj := map[string]interface{}{
|
||||
"enterprise": setting.Enterprise,
|
||||
"defaultDatasource": defaultDatasource,
|
||||
"datasources": datasources,
|
||||
"panels": panels,
|
||||
@@ -154,6 +153,7 @@ func getFrontendSettingsMap(c *m.ReqContext) (map[string]interface{}, error) {
|
||||
"latestVersion": plugins.GrafanaLatestVersion,
|
||||
"hasUpdate": plugins.GrafanaHasUpdate,
|
||||
"env": setting.Env,
|
||||
"isEnterprise": setting.IsEnterprise,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ func setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, error) {
|
||||
BuildCommit: setting.BuildCommit,
|
||||
NewGrafanaVersion: plugins.GrafanaLatestVersion,
|
||||
NewGrafanaVersionExists: plugins.GrafanaHasUpdate,
|
||||
AppName: setting.ApplicationName,
|
||||
}
|
||||
|
||||
if setting.DisableGravatar {
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/metrics"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
|
||||
_ "github.com/grafana/grafana/pkg/extensions"
|
||||
extensions "github.com/grafana/grafana/pkg/extensions"
|
||||
_ "github.com/grafana/grafana/pkg/services/alerting/conditions"
|
||||
_ "github.com/grafana/grafana/pkg/services/alerting/notifiers"
|
||||
_ "github.com/grafana/grafana/pkg/tsdb/cloudwatch"
|
||||
@@ -35,7 +35,6 @@ import (
|
||||
var version = "5.0.0"
|
||||
var commit = "NA"
|
||||
var buildstamp string
|
||||
var enterprise string
|
||||
|
||||
var configFile = flag.String("config", "", "path to config file")
|
||||
var homePath = flag.String("homepath", "", "path to grafana install/home path, defaults to working directory")
|
||||
@@ -78,7 +77,7 @@ func main() {
|
||||
setting.BuildVersion = version
|
||||
setting.BuildCommit = commit
|
||||
setting.BuildStamp = buildstampInt64
|
||||
setting.Enterprise, _ = strconv.ParseBool(enterprise)
|
||||
setting.IsEnterprise = extensions.IsEnterprise
|
||||
|
||||
metrics.M_Grafana_Version.WithLabelValues(version).Set(1)
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package extensions
|
||||
|
||||
import _ "github.com/pkg/errors"
|
||||
var IsEnterprise bool = false
|
||||
|
||||
@@ -334,6 +334,14 @@ func updateTotalStats() {
|
||||
|
||||
var usageStatsURL = "https://stats.grafana.org/grafana-usage-report"
|
||||
|
||||
func getEdition() string {
|
||||
if setting.IsEnterprise {
|
||||
return "enterprise"
|
||||
} else {
|
||||
return "oss"
|
||||
}
|
||||
}
|
||||
|
||||
func sendUsageStats() {
|
||||
if !setting.ReportingEnabled {
|
||||
return
|
||||
@@ -349,6 +357,7 @@ func sendUsageStats() {
|
||||
"metrics": metrics,
|
||||
"os": runtime.GOOS,
|
||||
"arch": runtime.GOARCH,
|
||||
"edition": getEdition(),
|
||||
}
|
||||
|
||||
statsQuery := models.GetSystemStatsQuery{}
|
||||
|
||||
@@ -18,9 +18,10 @@ import (
|
||||
|
||||
"github.com/go-macaron/session"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Scheme string
|
||||
@@ -49,7 +50,7 @@ var (
|
||||
BuildVersion string
|
||||
BuildCommit string
|
||||
BuildStamp int64
|
||||
Enterprise bool
|
||||
IsEnterprise bool
|
||||
ApplicationName string
|
||||
|
||||
// Paths
|
||||
@@ -517,7 +518,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
||||
Raw = cfg.Raw
|
||||
|
||||
ApplicationName = "Grafana"
|
||||
if Enterprise {
|
||||
if IsEnterprise {
|
||||
ApplicationName += " Enterprise"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user