mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 04:52:10 +08:00
29 lines
691 B
Go
29 lines
691 B
Go
package pluginassets
|
|
|
|
import (
|
|
"path"
|
|
"path/filepath"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins"
|
|
)
|
|
|
|
var _ Provider = (*LocalProvider)(nil)
|
|
|
|
type LocalProvider struct{}
|
|
|
|
func ProvideService() *LocalProvider {
|
|
return &LocalProvider{}
|
|
}
|
|
|
|
func (s *LocalProvider) Module(plugin PluginInfo) (string, error) {
|
|
if plugin.Class == plugins.ClassCore && filepath.Base(plugin.FS.Base()) != "dist" {
|
|
return path.Join("core:plugin", filepath.Base(plugin.FS.Base())), nil
|
|
}
|
|
|
|
return s.AssetPath(plugin, "module.js")
|
|
}
|
|
|
|
func (s *LocalProvider) AssetPath(plugin PluginInfo, assetPath ...string) (string, error) {
|
|
return path.Join("public/plugins", plugin.JsonData.ID, path.Join(assetPath...)), nil
|
|
}
|