mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 12:22:15 +08:00
Plugins: Move alias support to plugin json (but still hardcoded) (#75129)
This commit is contained in:
@ -107,14 +107,15 @@ func Test_ReadPluginJSON(t *testing.T) {
|
||||
pluginJSON: func(t *testing.T) io.ReadCloser {
|
||||
pJSON := `{
|
||||
"id": "grafana-pyroscope-datasource",
|
||||
"type": "datasource"
|
||||
"type": "datasource",
|
||||
"aliasIDs": ["phlare"]
|
||||
}`
|
||||
return io.NopCloser(strings.NewReader(pJSON))
|
||||
},
|
||||
expected: JSONData{
|
||||
ID: "grafana-pyroscope-datasource",
|
||||
Alias: "phlare", // Hardcoded from the parser
|
||||
Type: TypeDataSource,
|
||||
ID: "grafana-pyroscope-datasource",
|
||||
AliasIDs: []string{"phlare"}, // Hardcoded from the parser
|
||||
Type: TypeDataSource,
|
||||
Dependencies: Dependencies{
|
||||
GrafanaDependency: "",
|
||||
GrafanaVersion: "*",
|
||||
@ -122,6 +123,24 @@ func Test_ReadPluginJSON(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "do not allow alias except for our hardcoded set",
|
||||
pluginJSON: func(t *testing.T) io.ReadCloser {
|
||||
pJSON := `{
|
||||
"id": "my-custom-app",
|
||||
"type": "app",
|
||||
"aliasIDs": ["phlare"]
|
||||
}`
|
||||
return io.NopCloser(strings.NewReader(pJSON))
|
||||
},
|
||||
err: ErrUnsupportedAlias,
|
||||
expected: JSONData{
|
||||
ID: "my-custom-app",
|
||||
AliasIDs: []string{"phlare"}, // Hardcoded from the parser
|
||||
Type: "app",
|
||||
Dependencies: Dependencies{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
Reference in New Issue
Block a user