Plugins: Move alias support to plugin json (but still hardcoded) (#75129)

This commit is contained in:
Ryan McKinley
2023-09-29 08:20:37 -07:00
committed by GitHub
parent e45867c635
commit 010b2461b9
16 changed files with 90 additions and 53 deletions

View File

@ -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 {