Plugins: Remove unused funcs and re-use enum types (#63813)

plugins tidy
This commit is contained in:
Will Browne
2023-02-27 18:03:55 +00:00
committed by GitHub
parent 8484d0c4ef
commit 25b3abece9

View File

@ -3,6 +3,7 @@ package plugins
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io/fs" "io/fs"
"os" "os"
@ -20,7 +21,7 @@ import (
"github.com/grafana/grafana/pkg/util" "github.com/grafana/grafana/pkg/util"
) )
var ErrFileNotExist = fmt.Errorf("file does not exist") var ErrFileNotExist = errors.New("file does not exist")
type Plugin struct { type Plugin struct {
JSONData JSONData
@ -90,14 +91,6 @@ func (p PluginDTO) IsCorePlugin() bool {
return p.Class == Core return p.Class == Core
} }
func (p PluginDTO) IsExternalPlugin() bool {
return p.Class == External
}
func (p PluginDTO) IsSecretsManager() bool {
return p.JSONData.Type == SecretsManager
}
func (p PluginDTO) File(name string) (fs.File, error) { func (p PluginDTO) File(name string) (fs.File, error) {
cleanPath, err := util.CleanRelativePath(name) cleanPath, err := util.CleanRelativePath(name)
if err != nil { if err != nil {
@ -403,23 +396,15 @@ func (p *Plugin) StaticRoute() *StaticRoute {
} }
func (p *Plugin) IsRenderer() bool { func (p *Plugin) IsRenderer() bool {
return p.Type == "renderer" return p.Type == Renderer
} }
func (p *Plugin) IsSecretsManager() bool { func (p *Plugin) IsSecretsManager() bool {
return p.Type == "secretsmanager" return p.Type == SecretsManager
}
func (p *Plugin) IsDataSource() bool {
return p.Type == "datasource"
}
func (p *Plugin) IsPanel() bool {
return p.Type == "panel"
} }
func (p *Plugin) IsApp() bool { func (p *Plugin) IsApp() bool {
return p.Type == "app" return p.Type == App
} }
func (p *Plugin) IsCorePlugin() bool { func (p *Plugin) IsCorePlugin() bool {