mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
switch to using featureEnabled for enterprise features (#41559)
* switch to using featureEnabled for enterprise features
This commit is contained in:
@@ -196,11 +196,11 @@ func (i *Initializer) envVars(plugin *plugins.Plugin) []string {
|
||||
fmt.Sprintf("GF_VERSION=%s", i.cfg.BuildVersion),
|
||||
}
|
||||
|
||||
if i.license != nil && i.license.HasLicense() {
|
||||
if i.license != nil {
|
||||
hostEnv = append(
|
||||
hostEnv,
|
||||
fmt.Sprintf("GF_EDITION=%s", i.license.Edition()),
|
||||
fmt.Sprintf("GF_ENTERPRISE_license_PATH=%s", i.cfg.EnterpriseLicensePath),
|
||||
fmt.Sprintf("GF_ENTERPRISE_LICENSE_PATH=%s", i.cfg.EnterpriseLicensePath),
|
||||
)
|
||||
|
||||
if envProvider, ok := i.license.(models.LicenseEnvironment); ok {
|
||||
|
@@ -227,8 +227,8 @@ func TestInitializer_envVars(t *testing.T) {
|
||||
}
|
||||
|
||||
licensing := &testLicensingService{
|
||||
edition: "test",
|
||||
hasLicense: true,
|
||||
edition: "test",
|
||||
tokenRaw: "token",
|
||||
}
|
||||
|
||||
i := &Initializer{
|
||||
@@ -249,8 +249,8 @@ func TestInitializer_envVars(t *testing.T) {
|
||||
assert.Equal(t, "GF_PLUGIN_CUSTOM_ENV_VAR=customVal", envVars[0])
|
||||
assert.Equal(t, "GF_VERSION=", envVars[1])
|
||||
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_TEXT=", envVars[4])
|
||||
assert.Equal(t, "GF_ENTERPRISE_LICENSE_PATH=/path/to/ent/license", envVars[3])
|
||||
assert.Equal(t, "GF_ENTERPRISE_LICENSE_TEXT=token", envVars[4])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -314,13 +314,8 @@ func Test_pluginSettings_ToEnv(t *testing.T) {
|
||||
}
|
||||
|
||||
type testLicensingService struct {
|
||||
edition string
|
||||
hasLicense bool
|
||||
tokenRaw string
|
||||
}
|
||||
|
||||
func (t *testLicensingService) HasLicense() bool {
|
||||
return t.hasLicense
|
||||
edition string
|
||||
tokenRaw string
|
||||
}
|
||||
|
||||
func (t *testLicensingService) Expiry() int64 {
|
||||
@@ -343,14 +338,18 @@ func (t *testLicensingService) LicenseURL(showAdminLicensingPage bool) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (t *testLicensingService) HasValidLicense() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *testLicensingService) Environment() map[string]string {
|
||||
return map[string]string{"GF_ENTERPRISE_LICENSE_TEXT": t.tokenRaw}
|
||||
}
|
||||
|
||||
func (*testLicensingService) EnabledFeatures() map[string]bool {
|
||||
return map[string]bool{}
|
||||
}
|
||||
|
||||
func (*testLicensingService) FeatureEnabled(feature string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type testPlugin struct {
|
||||
backendplugin.Plugin
|
||||
}
|
||||
|
@@ -894,13 +894,8 @@ func newLoader(cfg *setting.Cfg) *Loader {
|
||||
}
|
||||
|
||||
type fakeLicensingService struct {
|
||||
edition string
|
||||
hasLicense bool
|
||||
tokenRaw string
|
||||
}
|
||||
|
||||
func (t *fakeLicensingService) HasLicense() bool {
|
||||
return t.hasLicense
|
||||
edition string
|
||||
tokenRaw string
|
||||
}
|
||||
|
||||
func (t *fakeLicensingService) Expiry() int64 {
|
||||
@@ -923,14 +918,18 @@ func (t *fakeLicensingService) LicenseURL(_ bool) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (t *fakeLicensingService) HasValidLicense() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *fakeLicensingService) Environment() map[string]string {
|
||||
return map[string]string{"GF_ENTERPRISE_LICENSE_TEXT": t.tokenRaw}
|
||||
}
|
||||
|
||||
func (*fakeLicensingService) EnabledFeatures() map[string]bool {
|
||||
return map[string]bool{}
|
||||
}
|
||||
|
||||
func (*fakeLicensingService) FeatureEnabled(feature string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type fakeLogger struct {
|
||||
log.Logger
|
||||
}
|
||||
|
Reference in New Issue
Block a user