mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
Licensing: Send the app url to plugin (#64258)
This commit is contained in:
parent
4625958aea
commit
0b0140b761
@ -99,6 +99,8 @@ type Licensing interface {
|
|||||||
Edition() string
|
Edition() string
|
||||||
|
|
||||||
Path() string
|
Path() string
|
||||||
|
|
||||||
|
AppURL() string
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleRegistry handles the plugin RBAC roles and their assignments
|
// RoleRegistry handles the plugin RBAC roles and their assignments
|
||||||
|
@ -9,12 +9,14 @@ import (
|
|||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
licensePath string
|
licensePath string
|
||||||
|
appURL string
|
||||||
license licensing.Licensing
|
license licensing.Licensing
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProvideLicensing(cfg *setting.Cfg, l licensing.Licensing) *Service {
|
func ProvideLicensing(cfg *setting.Cfg, l licensing.Licensing) *Service {
|
||||||
return &Service{
|
return &Service{
|
||||||
licensePath: cfg.EnterpriseLicensePath,
|
licensePath: cfg.EnterpriseLicensePath,
|
||||||
|
appURL: cfg.AppURL,
|
||||||
license: l,
|
license: l,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,3 +38,7 @@ func (l Service) Edition() string {
|
|||||||
func (l Service) Path() string {
|
func (l Service) Path() string {
|
||||||
return l.licensePath
|
return l.licensePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l Service) AppURL() string {
|
||||||
|
return l.appURL
|
||||||
|
}
|
||||||
|
@ -322,6 +322,7 @@ type FakeLicensingService struct {
|
|||||||
LicenseEdition string
|
LicenseEdition string
|
||||||
TokenRaw string
|
TokenRaw string
|
||||||
LicensePath string
|
LicensePath string
|
||||||
|
LicenseAppURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFakeLicensingService() *FakeLicensingService {
|
func NewFakeLicensingService() *FakeLicensingService {
|
||||||
@ -336,6 +337,10 @@ func (s *FakeLicensingService) Path() string {
|
|||||||
return s.LicensePath
|
return s.LicensePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *FakeLicensingService) AppURL() string {
|
||||||
|
return s.LicenseAppURL
|
||||||
|
}
|
||||||
|
|
||||||
func (s *FakeLicensingService) Environment() []string {
|
func (s *FakeLicensingService) Environment() []string {
|
||||||
return []string{fmt.Sprintf("GF_ENTERPRISE_LICENSE_TEXT=%s", s.TokenRaw)}
|
return []string{fmt.Sprintf("GF_ENTERPRISE_LICENSE_TEXT=%s", s.TokenRaw)}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ func (i *Initializer) envVars(plugin *plugins.Plugin) []string {
|
|||||||
hostEnv,
|
hostEnv,
|
||||||
fmt.Sprintf("GF_EDITION=%s", i.license.Edition()),
|
fmt.Sprintf("GF_EDITION=%s", i.license.Edition()),
|
||||||
fmt.Sprintf("GF_ENTERPRISE_LICENSE_PATH=%s", i.license.Path()),
|
fmt.Sprintf("GF_ENTERPRISE_LICENSE_PATH=%s", i.license.Path()),
|
||||||
|
fmt.Sprintf("GF_ENTERPRISE_APP_URL=%s", i.license.AppURL()),
|
||||||
)
|
)
|
||||||
hostEnv = append(hostEnv, i.license.Environment()...)
|
hostEnv = append(hostEnv, i.license.Environment()...)
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,7 @@ func TestInitializer_envVars(t *testing.T) {
|
|||||||
LicenseEdition: "test",
|
LicenseEdition: "test",
|
||||||
TokenRaw: "token",
|
TokenRaw: "token",
|
||||||
LicensePath: "/path/to/ent/license",
|
LicensePath: "/path/to/ent/license",
|
||||||
|
LicenseAppURL: "https://myorg.com/",
|
||||||
}
|
}
|
||||||
|
|
||||||
i := &Initializer{
|
i := &Initializer{
|
||||||
@ -158,12 +159,13 @@ func TestInitializer_envVars(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
envVars := i.envVars(p)
|
envVars := i.envVars(p)
|
||||||
assert.Len(t, envVars, 5)
|
assert.Len(t, envVars, 6)
|
||||||
assert.Equal(t, "GF_PLUGIN_CUSTOM_ENV_VAR=customVal", envVars[0])
|
assert.Equal(t, "GF_PLUGIN_CUSTOM_ENV_VAR=customVal", envVars[0])
|
||||||
assert.Equal(t, "GF_VERSION=", envVars[1])
|
assert.Equal(t, "GF_VERSION=", envVars[1])
|
||||||
assert.Equal(t, "GF_EDITION=test", envVars[2])
|
assert.Equal(t, "GF_EDITION=test", envVars[2])
|
||||||
assert.Equal(t, "GF_ENTERPRISE_LICENSE_PATH=/path/to/ent/license", envVars[3])
|
assert.Equal(t, "GF_ENTERPRISE_LICENSE_PATH=/path/to/ent/license", envVars[3])
|
||||||
assert.Equal(t, "GF_ENTERPRISE_LICENSE_TEXT=token", envVars[4])
|
assert.Equal(t, "GF_ENTERPRISE_APP_URL=https://myorg.com/", envVars[4])
|
||||||
|
assert.Equal(t, "GF_ENTERPRISE_LICENSE_TEXT=token", envVars[5])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user