mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Licensing: Send map of environment variables to plugins (#30347)
Replace hard-coded `GF_ENTERPRISE_LICENSE_TEXT` with a `map[string]string` to allow the licensing service to allow sending any environment variable through to the plugins for licensing purposes.
This commit is contained in:
parent
a246a26a2f
commit
af27dd7e7d
@ -16,6 +16,9 @@ type Licensing interface {
|
|||||||
LicenseURL(user *SignedInUser) string
|
LicenseURL(user *SignedInUser) string
|
||||||
|
|
||||||
StateInfo() string
|
StateInfo() string
|
||||||
|
}
|
||||||
TokenRaw() string
|
|
||||||
|
type LicenseEnvironment interface {
|
||||||
|
// Environment is a map of environment variables
|
||||||
|
Environment() map[string]string
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,13 @@ func (m *manager) Register(pluginID string, factory PluginFactoryFunc) error {
|
|||||||
hostEnv = append(
|
hostEnv = append(
|
||||||
hostEnv,
|
hostEnv,
|
||||||
fmt.Sprintf("GF_ENTERPRISE_LICENSE_PATH=%s", m.Cfg.EnterpriseLicensePath),
|
fmt.Sprintf("GF_ENTERPRISE_LICENSE_PATH=%s", m.Cfg.EnterpriseLicensePath),
|
||||||
fmt.Sprintf("GF_ENTERPRISE_LICENSE_TEXT=%s", m.License.TokenRaw()),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if envProvider, ok := m.License.(models.LicenseEnvironment); ok {
|
||||||
|
for k, v := range envProvider.Environment() {
|
||||||
|
hostEnv = append(hostEnv, fmt.Sprintf("%s=%s", k, v))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
env := pluginSettings.ToEnv("GF_PLUGIN", hostEnv)
|
env := pluginSettings.ToEnv("GF_PLUGIN", hostEnv)
|
||||||
|
@ -411,6 +411,6 @@ func (t *testLicensingService) HasValidLicense() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *testLicensingService) TokenRaw() string {
|
func (t *testLicensingService) Environment() map[string]string {
|
||||||
return t.tokenRaw
|
return map[string]string{"GF_ENTERPRISE_LICENSE_TEXT": t.tokenRaw}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,3 @@ func (l *OSSLicensingService) Init() error {
|
|||||||
func (*OSSLicensingService) HasValidLicense() bool {
|
func (*OSSLicensingService) HasValidLicense() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*OSSLicensingService) TokenRaw() string {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user