mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 16:42:36 +08:00
Plugins: Standardize Golang enum naming convention (#69449)
* standardize enum pattern * fix up
This commit is contained in:
@ -24,6 +24,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/manager/signature/statickey"
|
||||
"github.com/grafana/grafana/pkg/plugins/manager/sources"
|
||||
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
@ -71,14 +72,14 @@ func TestLoader_Load(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "Load a Core plugin",
|
||||
class: plugins.Core,
|
||||
class: plugins.ClassCore,
|
||||
cfg: &config.Cfg{},
|
||||
pluginPaths: []string{filepath.Join(corePluginDir, "app/plugins/datasource/cloudwatch")},
|
||||
want: []*plugins.Plugin{
|
||||
{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "cloudwatch",
|
||||
Type: "datasource",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "CloudWatch",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -114,21 +115,21 @@ func TestLoader_Load(t *testing.T) {
|
||||
BaseURL: "public/app/plugins/datasource/cloudwatch",
|
||||
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(corePluginDir, "app/plugins/datasource/cloudwatch")),
|
||||
Signature: plugins.SignatureInternal,
|
||||
Class: plugins.Core,
|
||||
Signature: plugins.SignatureStatusInternal,
|
||||
Class: plugins.ClassCore,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Load a Bundled plugin",
|
||||
class: plugins.Bundled,
|
||||
class: plugins.ClassBundled,
|
||||
cfg: &config.Cfg{},
|
||||
pluginPaths: []string{"../testdata/valid-v2-signature"},
|
||||
want: []*plugins.Plugin{
|
||||
{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test-datasource",
|
||||
Type: "datasource",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "Test",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -154,14 +155,14 @@ func TestLoader_Load(t *testing.T) {
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/valid-v2-signature/plugin/")),
|
||||
Signature: "valid",
|
||||
SignatureType: plugins.GrafanaSignature,
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Class: plugins.Bundled,
|
||||
Class: plugins.ClassBundled,
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: "Load plugin with symbolic links",
|
||||
class: plugins.External,
|
||||
class: plugins.ClassExternal,
|
||||
cfg: &config.Cfg{},
|
||||
pluginPaths: []string{"../testdata/symbolic-plugin-dirs"},
|
||||
want: []*plugins.Plugin{
|
||||
@ -203,41 +204,41 @@ func TestLoader_Load(t *testing.T) {
|
||||
Name: "Nginx Connections",
|
||||
Path: "dashboards/connections.json",
|
||||
Type: "dashboard",
|
||||
Role: "Viewer",
|
||||
Role: org.RoleViewer,
|
||||
Slug: "nginx-connections",
|
||||
},
|
||||
{
|
||||
Name: "Nginx Memory",
|
||||
Path: "dashboards/memory.json",
|
||||
Type: "dashboard",
|
||||
Role: "Viewer",
|
||||
Role: org.RoleViewer,
|
||||
Slug: "nginx-memory",
|
||||
},
|
||||
{
|
||||
Name: "Nginx Panel",
|
||||
Type: "panel",
|
||||
Role: "Viewer",
|
||||
Type: string(plugins.TypePanel),
|
||||
Role: org.RoleViewer,
|
||||
Slug: "nginx-panel"},
|
||||
{
|
||||
Name: "Nginx Datasource",
|
||||
Type: "datasource",
|
||||
Role: "Viewer",
|
||||
Type: string(plugins.TypeDataSource),
|
||||
Role: org.RoleViewer,
|
||||
Slug: "nginx-datasource",
|
||||
},
|
||||
},
|
||||
},
|
||||
Class: plugins.External,
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "plugins/test-app/module",
|
||||
BaseURL: "public/plugins/test-app",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/includes-symlinks")),
|
||||
Signature: "valid",
|
||||
SignatureType: plugins.GrafanaSignature,
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: "Load an unsigned plugin (development)",
|
||||
class: plugins.External,
|
||||
class: plugins.ClassExternal,
|
||||
cfg: &config.Cfg{
|
||||
DevMode: true,
|
||||
},
|
||||
@ -246,7 +247,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test-datasource",
|
||||
Type: "datasource",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "Test",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -264,9 +265,9 @@ func TestLoader_Load(t *testing.T) {
|
||||
Plugins: []plugins.Dependency{},
|
||||
},
|
||||
Backend: true,
|
||||
State: plugins.AlphaRelease,
|
||||
State: plugins.ReleaseStateAlpha,
|
||||
},
|
||||
Class: plugins.External,
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "plugins/test-datasource/module",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/unsigned-datasource/plugin")),
|
||||
@ -275,7 +276,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
},
|
||||
}, {
|
||||
name: "Load an unsigned plugin (production)",
|
||||
class: plugins.External,
|
||||
class: plugins.ClassExternal,
|
||||
cfg: &config.Cfg{},
|
||||
pluginPaths: []string{"../testdata/unsigned-datasource"},
|
||||
want: []*plugins.Plugin{},
|
||||
@ -288,7 +289,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Load an unsigned plugin using PluginsAllowUnsigned config (production)",
|
||||
class: plugins.External,
|
||||
class: plugins.ClassExternal,
|
||||
cfg: &config.Cfg{
|
||||
PluginsAllowUnsigned: []string{"test-datasource"},
|
||||
},
|
||||
@ -297,7 +298,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test-datasource",
|
||||
Type: "datasource",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "Test",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -315,19 +316,19 @@ func TestLoader_Load(t *testing.T) {
|
||||
Plugins: []plugins.Dependency{},
|
||||
},
|
||||
Backend: true,
|
||||
State: plugins.AlphaRelease,
|
||||
State: plugins.ReleaseStateAlpha,
|
||||
},
|
||||
Class: plugins.External,
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "plugins/test-datasource/module",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/unsigned-datasource/plugin")),
|
||||
Signature: plugins.SignatureUnsigned,
|
||||
Signature: plugins.SignatureStatusUnsigned,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Load a plugin with v1 manifest should return signatureInvalid",
|
||||
class: plugins.External,
|
||||
class: plugins.ClassExternal,
|
||||
cfg: &config.Cfg{},
|
||||
pluginPaths: []string{"../testdata/lacking-files"},
|
||||
want: []*plugins.Plugin{},
|
||||
@ -340,7 +341,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Load a plugin with v1 manifest using PluginsAllowUnsigned config (production) should return signatureInvali",
|
||||
class: plugins.External,
|
||||
class: plugins.ClassExternal,
|
||||
cfg: &config.Cfg{
|
||||
PluginsAllowUnsigned: []string{"test-datasource"},
|
||||
},
|
||||
@ -355,7 +356,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Load a plugin with manifest which has a file not found in plugin folder",
|
||||
class: plugins.External,
|
||||
class: plugins.ClassExternal,
|
||||
cfg: &config.Cfg{
|
||||
PluginsAllowUnsigned: []string{"test-datasource"},
|
||||
},
|
||||
@ -370,7 +371,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Load a plugin with file which is missing from the manifest",
|
||||
class: plugins.External,
|
||||
class: plugins.ClassExternal,
|
||||
cfg: &config.Cfg{
|
||||
PluginsAllowUnsigned: []string{"test-datasource"},
|
||||
},
|
||||
@ -385,7 +386,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Load an app with includes",
|
||||
class: plugins.External,
|
||||
class: plugins.ClassExternal,
|
||||
cfg: &config.Cfg{
|
||||
PluginsAllowUnsigned: []string{"test-app"},
|
||||
},
|
||||
@ -393,7 +394,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
want: []*plugins.Plugin{
|
||||
{JSONData: plugins.JSONData{
|
||||
ID: "test-app",
|
||||
Type: "app",
|
||||
Type: plugins.TypeApp,
|
||||
Name: "Test App",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -418,15 +419,15 @@ func TestLoader_Load(t *testing.T) {
|
||||
Plugins: []plugins.Dependency{},
|
||||
},
|
||||
Includes: []*plugins.Includes{
|
||||
{Name: "Nginx Memory", Path: "dashboards/memory.json", Type: "dashboard", Role: "Viewer", Slug: "nginx-memory"},
|
||||
{Name: "Root Page (react)", Type: "page", Role: "Viewer", Path: "/a/my-simple-app", DefaultNav: true, AddToNav: true, Slug: "root-page-react"},
|
||||
{Name: "Nginx Memory", Path: "dashboards/memory.json", Type: "dashboard", Role: org.RoleViewer, Slug: "nginx-memory"},
|
||||
{Name: "Root Page (react)", Type: "page", Role: org.RoleViewer, Path: "/a/my-simple-app", DefaultNav: true, AddToNav: true, Slug: "root-page-react"},
|
||||
},
|
||||
Backend: false,
|
||||
},
|
||||
DefaultNavURL: "/plugins/test-app/page/root-page-react",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/test-app-with-includes")),
|
||||
Class: plugins.External,
|
||||
Signature: plugins.SignatureUnsigned,
|
||||
Class: plugins.ClassExternal,
|
||||
Signature: plugins.SignatureStatusUnsigned,
|
||||
Module: "plugins/test-app/module",
|
||||
BaseURL: "public/plugins/test-app",
|
||||
},
|
||||
@ -480,7 +481,7 @@ func TestLoader_Load_CustomSource(t *testing.T) {
|
||||
expected := []*plugins.Plugin{{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "grafana-worldmap-panel",
|
||||
Type: "panel",
|
||||
Type: plugins.TypePanel,
|
||||
Name: "Worldmap Panel",
|
||||
Info: plugins.Info{
|
||||
Version: "0.3.3",
|
||||
@ -514,8 +515,8 @@ func TestLoader_Load_CustomSource(t *testing.T) {
|
||||
},
|
||||
},
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/cdn/plugin")),
|
||||
Class: plugins.Bundled,
|
||||
Signature: plugins.SignatureValid,
|
||||
Class: plugins.ClassBundled,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
BaseURL: "plugin-cdn/grafana-worldmap-panel/0.3.3/public/plugins/grafana-worldmap-panel",
|
||||
Module: "plugin-cdn/grafana-worldmap-panel/0.3.3/public/plugins/grafana-worldmap-panel/module",
|
||||
}}
|
||||
@ -523,14 +524,14 @@ func TestLoader_Load_CustomSource(t *testing.T) {
|
||||
l := newLoader(cfg)
|
||||
got, err := l.Load(context.Background(), &fakes.FakePluginSource{
|
||||
PluginClassFunc: func(ctx context.Context) plugins.Class {
|
||||
return plugins.Bundled
|
||||
return plugins.ClassBundled
|
||||
},
|
||||
PluginURIsFunc: func(ctx context.Context) []string {
|
||||
return pluginPaths
|
||||
},
|
||||
DefaultSignatureFunc: func(ctx context.Context) (plugins.Signature, bool) {
|
||||
return plugins.Signature{
|
||||
Status: plugins.SignatureValid,
|
||||
Status: plugins.SignatureStatusValid,
|
||||
}, true
|
||||
},
|
||||
})
|
||||
@ -627,7 +628,7 @@ func TestLoader_Load_MultiplePlugins(t *testing.T) {
|
||||
{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test-datasource",
|
||||
Type: "datasource",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "Test",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -647,14 +648,14 @@ func TestLoader_Load_MultiplePlugins(t *testing.T) {
|
||||
},
|
||||
Backend: true,
|
||||
Executable: "test",
|
||||
State: plugins.AlphaRelease,
|
||||
State: plugins.ReleaseStateAlpha,
|
||||
},
|
||||
Class: plugins.External,
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "plugins/test-datasource/module",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/valid-v2-pvt-signature/plugin")),
|
||||
Signature: "valid",
|
||||
SignatureType: plugins.PrivateSignature,
|
||||
SignatureType: plugins.SignatureTypePrivate,
|
||||
SignatureOrg: "Will Browne",
|
||||
},
|
||||
},
|
||||
@ -685,7 +686,7 @@ func TestLoader_Load_MultiplePlugins(t *testing.T) {
|
||||
|
||||
got, err := l.Load(context.Background(), &fakes.FakePluginSource{
|
||||
PluginClassFunc: func(ctx context.Context) plugins.Class {
|
||||
return plugins.External
|
||||
return plugins.ClassExternal
|
||||
},
|
||||
PluginURIsFunc: func(ctx context.Context) []string {
|
||||
return tt.pluginPaths
|
||||
@ -733,7 +734,7 @@ func TestLoader_Load_RBACReady(t *testing.T) {
|
||||
{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test-app",
|
||||
Type: "app",
|
||||
Type: plugins.TypeApp,
|
||||
Name: "Test App",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -772,9 +773,9 @@ func TestLoader_Load_RBACReady(t *testing.T) {
|
||||
Backend: false,
|
||||
},
|
||||
FS: mustNewStaticFSForTests(t, pluginDir),
|
||||
Class: plugins.External,
|
||||
Signature: plugins.SignatureValid,
|
||||
SignatureType: plugins.PrivateSignature,
|
||||
Class: plugins.ClassExternal,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
SignatureType: plugins.SignatureTypePrivate,
|
||||
SignatureOrg: "gabrielmabille",
|
||||
Module: "plugins/test-app/module",
|
||||
BaseURL: "public/plugins/test-app",
|
||||
@ -800,7 +801,7 @@ func TestLoader_Load_RBACReady(t *testing.T) {
|
||||
|
||||
got, err := l.Load(context.Background(), &fakes.FakePluginSource{
|
||||
PluginClassFunc: func(ctx context.Context) plugins.Class {
|
||||
return plugins.External
|
||||
return plugins.ClassExternal
|
||||
},
|
||||
PluginURIsFunc: func(ctx context.Context) []string {
|
||||
return tt.pluginPaths
|
||||
@ -842,7 +843,7 @@ func TestLoader_Load_Signature_RootURL(t *testing.T) {
|
||||
{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test-datasource",
|
||||
Type: "datasource",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "Test",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{Name: "Will Browne", URL: "https://willbrowne.com"},
|
||||
@ -853,15 +854,15 @@ func TestLoader_Load_Signature_RootURL(t *testing.T) {
|
||||
},
|
||||
Version: "1.0.0",
|
||||
},
|
||||
State: plugins.AlphaRelease,
|
||||
State: plugins.ReleaseStateAlpha,
|
||||
Dependencies: plugins.Dependencies{GrafanaVersion: "*", Plugins: []plugins.Dependency{}},
|
||||
Backend: true,
|
||||
Executable: "test",
|
||||
},
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "/testdata/valid-v2-pvt-signature-root-url-uri/plugin")),
|
||||
Class: plugins.External,
|
||||
Signature: plugins.SignatureValid,
|
||||
SignatureType: plugins.PrivateSignature,
|
||||
Class: plugins.ClassExternal,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
SignatureType: plugins.SignatureTypePrivate,
|
||||
SignatureOrg: "Will Browne",
|
||||
Module: "plugins/test-datasource/module",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
@ -878,7 +879,7 @@ func TestLoader_Load_Signature_RootURL(t *testing.T) {
|
||||
})
|
||||
got, err := l.Load(context.Background(), &fakes.FakePluginSource{
|
||||
PluginClassFunc: func(ctx context.Context) plugins.Class {
|
||||
return plugins.External
|
||||
return plugins.ClassExternal
|
||||
},
|
||||
PluginURIsFunc: func(ctx context.Context) []string {
|
||||
return paths
|
||||
@ -904,7 +905,7 @@ func TestLoader_Load_DuplicatePlugins(t *testing.T) {
|
||||
{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test-app",
|
||||
Type: "app",
|
||||
Type: plugins.TypeApp,
|
||||
Name: "Test App",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -935,17 +936,17 @@ func TestLoader_Load_DuplicatePlugins(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Includes: []*plugins.Includes{
|
||||
{Name: "Nginx Connections", Path: "dashboards/connections.json", Type: "dashboard", Role: "Viewer", Slug: "nginx-connections"},
|
||||
{Name: "Nginx Memory", Path: "dashboards/memory.json", Type: "dashboard", Role: "Viewer", Slug: "nginx-memory"},
|
||||
{Name: "Nginx Panel", Type: "panel", Role: "Viewer", Slug: "nginx-panel"},
|
||||
{Name: "Nginx Datasource", Type: "datasource", Role: "Viewer", Slug: "nginx-datasource"},
|
||||
{Name: "Nginx Connections", Path: "dashboards/connections.json", Type: "dashboard", Role: org.RoleViewer, Slug: "nginx-connections"},
|
||||
{Name: "Nginx Memory", Path: "dashboards/memory.json", Type: "dashboard", Role: org.RoleViewer, Slug: "nginx-memory"},
|
||||
{Name: "Nginx Panel", Type: "panel", Role: org.RoleViewer, Slug: "nginx-panel"},
|
||||
{Name: "Nginx Datasource", Type: "datasource", Role: org.RoleViewer, Slug: "nginx-datasource"},
|
||||
},
|
||||
Backend: false,
|
||||
},
|
||||
FS: mustNewStaticFSForTests(t, pluginDir),
|
||||
Class: plugins.External,
|
||||
Signature: plugins.SignatureValid,
|
||||
SignatureType: plugins.GrafanaSignature,
|
||||
Class: plugins.ClassExternal,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Module: "plugins/test-app/module",
|
||||
BaseURL: "public/plugins/test-app",
|
||||
@ -962,7 +963,7 @@ func TestLoader_Load_DuplicatePlugins(t *testing.T) {
|
||||
})
|
||||
got, err := l.Load(context.Background(), &fakes.FakePluginSource{
|
||||
PluginClassFunc: func(ctx context.Context) plugins.Class {
|
||||
return plugins.External
|
||||
return plugins.ClassExternal
|
||||
},
|
||||
PluginURIsFunc: func(ctx context.Context) []string {
|
||||
return []string{pluginDir, pluginDir}
|
||||
@ -994,7 +995,7 @@ func TestLoader_Load_SkipUninitializedPlugins(t *testing.T) {
|
||||
{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test-app",
|
||||
Type: "app",
|
||||
Type: plugins.TypeApp,
|
||||
Name: "Test App",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -1025,17 +1026,17 @@ func TestLoader_Load_SkipUninitializedPlugins(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Includes: []*plugins.Includes{
|
||||
{Name: "Nginx Connections", Path: "dashboards/connections.json", Type: "dashboard", Role: "Viewer", Slug: "nginx-connections"},
|
||||
{Name: "Nginx Memory", Path: "dashboards/memory.json", Type: "dashboard", Role: "Viewer", Slug: "nginx-memory"},
|
||||
{Name: "Nginx Panel", Type: "panel", Role: "Viewer", Slug: "nginx-panel"},
|
||||
{Name: "Nginx Datasource", Type: "datasource", Role: "Viewer", Slug: "nginx-datasource"},
|
||||
{Name: "Nginx Connections", Path: "dashboards/connections.json", Type: "dashboard", Role: org.RoleViewer, Slug: "nginx-connections"},
|
||||
{Name: "Nginx Memory", Path: "dashboards/memory.json", Type: "dashboard", Role: org.RoleViewer, Slug: "nginx-memory"},
|
||||
{Name: "Nginx Panel", Type: "panel", Role: org.RoleViewer, Slug: "nginx-panel"},
|
||||
{Name: "Nginx Datasource", Type: "datasource", Role: org.RoleViewer, Slug: "nginx-datasource"},
|
||||
},
|
||||
Backend: false,
|
||||
},
|
||||
FS: mustNewStaticFSForTests(t, pluginDir1),
|
||||
Class: plugins.External,
|
||||
Signature: plugins.SignatureValid,
|
||||
SignatureType: plugins.GrafanaSignature,
|
||||
Class: plugins.ClassExternal,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Module: "plugins/test-app/module",
|
||||
BaseURL: "public/plugins/test-app",
|
||||
@ -1061,7 +1062,7 @@ func TestLoader_Load_SkipUninitializedPlugins(t *testing.T) {
|
||||
})
|
||||
got, err := l.Load(context.Background(), &fakes.FakePluginSource{
|
||||
PluginClassFunc: func(ctx context.Context) plugins.Class {
|
||||
return plugins.External
|
||||
return plugins.ClassExternal
|
||||
},
|
||||
PluginURIsFunc: func(ctx context.Context) []string {
|
||||
return []string{pluginDir1, pluginDir2}
|
||||
@ -1080,7 +1081,7 @@ func TestLoader_Load_SkipUninitializedPlugins(t *testing.T) {
|
||||
func TestLoader_Load_Angular(t *testing.T) {
|
||||
fakePluginSource := &fakes.FakePluginSource{
|
||||
PluginClassFunc: func(ctx context.Context) plugins.Class {
|
||||
return plugins.External
|
||||
return plugins.ClassExternal
|
||||
},
|
||||
PluginURIsFunc: func(ctx context.Context) []string {
|
||||
return []string{"../testdata/valid-v2-signature"}
|
||||
@ -1138,7 +1139,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
parent := &plugins.Plugin{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test-datasource",
|
||||
Type: "datasource",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "Parent",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -1162,16 +1163,16 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
Module: "plugins/test-datasource/module",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(rootDir, "testdata/nested-plugins/parent")),
|
||||
Signature: plugins.SignatureValid,
|
||||
SignatureType: plugins.GrafanaSignature,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Class: plugins.External,
|
||||
Class: plugins.ClassExternal,
|
||||
}
|
||||
|
||||
child := &plugins.Plugin{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test-panel",
|
||||
Type: "panel",
|
||||
Type: plugins.TypePanel,
|
||||
Name: "Child",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -1194,10 +1195,10 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
Module: "plugins/test-panel/module",
|
||||
BaseURL: "public/plugins/test-panel",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(rootDir, "testdata/nested-plugins/parent/nested")),
|
||||
Signature: plugins.SignatureValid,
|
||||
SignatureType: plugins.GrafanaSignature,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Class: plugins.External,
|
||||
Class: plugins.ClassExternal,
|
||||
}
|
||||
|
||||
parent.Children = []*plugins.Plugin{child}
|
||||
@ -1215,7 +1216,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
|
||||
got, err := l.Load(context.Background(), &fakes.FakePluginSource{
|
||||
PluginClassFunc: func(ctx context.Context) plugins.Class {
|
||||
return plugins.External
|
||||
return plugins.ClassExternal
|
||||
},
|
||||
PluginURIsFunc: func(ctx context.Context) []string {
|
||||
return []string{"../testdata/nested-plugins"}
|
||||
@ -1238,7 +1239,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
t.Run("Load will exclude plugins that already exist", func(t *testing.T) {
|
||||
got, err := l.Load(context.Background(), &fakes.FakePluginSource{
|
||||
PluginClassFunc: func(ctx context.Context) plugins.Class {
|
||||
return plugins.External
|
||||
return plugins.ClassExternal
|
||||
},
|
||||
PluginURIsFunc: func(ctx context.Context) []string {
|
||||
return []string{"../testdata/nested-plugins"}
|
||||
@ -1263,7 +1264,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
parent := &plugins.Plugin{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "myorgid-simple-app",
|
||||
Type: "app",
|
||||
Type: plugins.TypeApp,
|
||||
Name: "Simple App",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -1292,7 +1293,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
Name: "Root Page (react)",
|
||||
Path: "/a/myorgid-simple-app",
|
||||
Type: "page",
|
||||
Role: "Viewer",
|
||||
Role: org.RoleViewer,
|
||||
AddToNav: true,
|
||||
DefaultNav: true,
|
||||
Slug: "root-page-react",
|
||||
@ -1301,7 +1302,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
Name: "Root Page (Tab B)",
|
||||
Path: "/a/myorgid-simple-app/?tab=b",
|
||||
Type: "page",
|
||||
Role: "Viewer",
|
||||
Role: org.RoleViewer,
|
||||
AddToNav: true,
|
||||
Slug: "root-page-tab-b",
|
||||
},
|
||||
@ -1309,7 +1310,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
Name: "React Config",
|
||||
Path: "/plugins/myorgid-simple-app/?page=page2",
|
||||
Type: "page",
|
||||
Role: "Admin",
|
||||
Role: org.RoleAdmin,
|
||||
AddToNav: true,
|
||||
Slug: "react-config",
|
||||
},
|
||||
@ -1317,14 +1318,14 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
Name: "Streaming Example",
|
||||
Path: "dashboards/streaming.json",
|
||||
Type: "dashboard",
|
||||
Role: "Viewer",
|
||||
Role: org.RoleViewer,
|
||||
Slug: "streaming-example",
|
||||
},
|
||||
{
|
||||
Name: "Lots of Stats",
|
||||
Path: "dashboards/stats.json",
|
||||
Type: "dashboard",
|
||||
Role: "Viewer",
|
||||
Role: org.RoleViewer,
|
||||
Slug: "lots-of-stats",
|
||||
},
|
||||
},
|
||||
@ -1334,16 +1335,16 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
BaseURL: "public/plugins/myorgid-simple-app",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(rootDir, "testdata/app-with-child/dist")),
|
||||
DefaultNavURL: "/plugins/myorgid-simple-app/page/root-page-react",
|
||||
Signature: plugins.SignatureValid,
|
||||
SignatureType: plugins.GrafanaSignature,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Class: plugins.External,
|
||||
Class: plugins.ClassExternal,
|
||||
}
|
||||
|
||||
child := &plugins.Plugin{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "myorgid-simple-panel",
|
||||
Type: "panel",
|
||||
Type: plugins.TypePanel,
|
||||
Name: "Grafana Panel Plugin Template",
|
||||
Info: plugins.Info{
|
||||
Author: plugins.InfoLink{
|
||||
@ -1372,10 +1373,10 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
BaseURL: "public/plugins/myorgid-simple-app",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(rootDir, "testdata/app-with-child/dist/child")),
|
||||
IncludedInAppID: parent.ID,
|
||||
Signature: plugins.SignatureValid,
|
||||
SignatureType: plugins.GrafanaSignature,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Class: plugins.External,
|
||||
Class: plugins.ClassExternal,
|
||||
}
|
||||
|
||||
parent.Children = []*plugins.Plugin{child}
|
||||
@ -1392,7 +1393,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
})
|
||||
got, err := l.Load(context.Background(), &fakes.FakePluginSource{
|
||||
PluginClassFunc: func(ctx context.Context) plugins.Class {
|
||||
return plugins.External
|
||||
return plugins.ClassExternal
|
||||
},
|
||||
PluginURIsFunc: func(ctx context.Context) []string {
|
||||
return []string{"../testdata/app-with-child"}
|
||||
@ -1420,10 +1421,10 @@ func Test_setPathsBasedOnApp(t *testing.T) {
|
||||
}
|
||||
parent := &plugins.Plugin{
|
||||
JSONData: plugins.JSONData{
|
||||
Type: plugins.App,
|
||||
Type: plugins.TypeApp,
|
||||
ID: "testdata-app",
|
||||
},
|
||||
Class: plugins.Core,
|
||||
Class: plugins.ClassCore,
|
||||
FS: fakes.NewFakePluginFiles("c:\\grafana\\public\\app\\plugins\\app\\testdata-app"),
|
||||
BaseURL: "public/app/plugins/app/testdata-app",
|
||||
}
|
||||
|
Reference in New Issue
Block a user