Licensing service (#19903)
* Licensing: supplies a service to handle licensing information * Licensing: uses the license service further Uses the license service instead of settings.isEnterprise: - external team members - saml - usage stats * Licensing: fixes broken tests due to new Licensing service dependency * Licensing: fixes linting errors * Licensing: exposes license expiry information to the frontend
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/login/social"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
@@ -23,6 +24,7 @@ type UsageStatsService struct {
|
||||
Cfg *setting.Cfg `inject:""`
|
||||
Bus bus.Bus `inject:""`
|
||||
SQLStore *sqlstore.SqlStore `inject:""`
|
||||
License models.Licensing `inject:""`
|
||||
|
||||
oauthProviders map[string]bool
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func (uss *UsageStatsService) sendUsageStats(oauthProviders map[string]bool) {
|
||||
"metrics": metrics,
|
||||
"os": runtime.GOOS,
|
||||
"arch": runtime.GOARCH,
|
||||
"edition": getEdition(),
|
||||
"edition": getEdition(uss.License.HasValidLicense()),
|
||||
"packaging": setting.Packaging,
|
||||
}
|
||||
|
||||
@@ -182,8 +182,8 @@ func (uss *UsageStatsService) updateTotalStats() {
|
||||
metrics.StatsTotalActiveAdmins.Set(float64(statsQuery.Result.ActiveAdmins))
|
||||
}
|
||||
|
||||
func getEdition() string {
|
||||
if setting.IsEnterprise {
|
||||
func getEdition(validLicense bool) string {
|
||||
if validLicense {
|
||||
return "enterprise"
|
||||
}
|
||||
return "oss"
|
||||
|
||||
@@ -25,6 +25,7 @@ func TestMetrics(t *testing.T) {
|
||||
uss := &UsageStatsService{
|
||||
Bus: bus.New(),
|
||||
SQLStore: sqlstore.InitTestDB(t),
|
||||
License: models.OSSLicensingService{},
|
||||
}
|
||||
|
||||
var getSystemStatsQuery *models.GetSystemStatsQuery
|
||||
|
||||
Reference in New Issue
Block a user