mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 12:14:08 -06:00
c04bc805b5
* CDN: Initial poc support for serving assets over a CDN * Minor fix * added build path and test * fix lint error * Added edition to cdn path * Move master builds to a separate path * Added error handling for the url parsing, changed setting name, and added docs * Updated sample.ini * Some property renames * updated * Minor update to html * index template improvements * Update docs/sources/administration/configuration.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/administration/configuration.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Added ContentDeliveryPrefix to Licence service * updated docs * Updated test mock Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package licensing
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/api/dtos"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/services/hooks"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
const (
|
|
openSource = "Open Source"
|
|
)
|
|
|
|
type OSSLicensingService struct {
|
|
Cfg *setting.Cfg `inject:""`
|
|
HooksService *hooks.HooksService `inject:""`
|
|
}
|
|
|
|
func (*OSSLicensingService) HasLicense() bool {
|
|
return false
|
|
}
|
|
|
|
func (*OSSLicensingService) Expiry() int64 {
|
|
return 0
|
|
}
|
|
|
|
func (*OSSLicensingService) Edition() string {
|
|
return openSource
|
|
}
|
|
|
|
func (*OSSLicensingService) StateInfo() string {
|
|
return ""
|
|
}
|
|
|
|
func (*OSSLicensingService) ContentDeliveryPrefix() string {
|
|
return "grafana-oss"
|
|
}
|
|
|
|
func (l *OSSLicensingService) LicenseURL(user *models.SignedInUser) string {
|
|
if user.IsGrafanaAdmin {
|
|
return l.Cfg.AppSubURL + "/admin/upgrading"
|
|
}
|
|
|
|
return "https://grafana.com/products/enterprise/?utm_source=grafana_footer"
|
|
}
|
|
|
|
func (l *OSSLicensingService) Init() error {
|
|
l.HooksService.AddIndexDataHook(func(indexData *dtos.IndexViewData, req *models.ReqContext) {
|
|
for _, node := range indexData.NavTree {
|
|
if node.Id == "admin" {
|
|
node.Children = append(node.Children, &dtos.NavLink{
|
|
Text: "Upgrade",
|
|
Id: "upgrading",
|
|
Url: l.LicenseURL(req.SignedInUser),
|
|
Icon: "unlock",
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
return nil
|
|
}
|
|
|
|
func (*OSSLicensingService) HasValidLicense() bool {
|
|
return false
|
|
}
|