Plugins: Add tailored interface for plugins licensing needs (#61045)

* tailored licensing service

* appease linter

* fix

* retrigger
This commit is contained in:
Will Browne
2023-01-18 18:02:54 +01:00
committed by GitHub
parent 61d8ab71a3
commit c54aa18cd8
9 changed files with 76 additions and 87 deletions
+38
View File
@@ -0,0 +1,38 @@
package licensing
import (
"fmt"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
)
type Service struct {
licensePath string
license models.Licensing
}
func ProvideLicensing(cfg *setting.Cfg, l models.Licensing) *Service {
return &Service{
licensePath: cfg.EnterpriseLicensePath,
license: l,
}
}
func (l Service) Environment() []string {
var env []string
if envProvider, ok := l.license.(models.LicenseEnvironment); ok {
for k, v := range envProvider.Environment() {
env = append(env, fmt.Sprintf("%s=%s", k, v))
}
}
return env
}
func (l Service) Edition() string {
return l.license.Edition()
}
func (l Service) Path() string {
return l.licensePath
}