SSE: Add functions that determine NodeType by UID and construct a data source struct from NodeType (#70106)

* add NodeTypeFromDatasourceUID and DataSourceModelFromNodeType()
* deprecate expr.DataSourceModel
* replace usages of IsDataSource to NodeTypeFromDatasourceUID 
* replace usages of DataSourceModel to DataSourceModelFromNodeType()
This commit is contained in:
Yuri Tseretyan
2023-06-16 13:05:06 -04:00
committed by GitHub
parent 3d15d54a71
commit 842f33580e
7 changed files with 76 additions and 40 deletions
+6 -1
View File
@@ -62,7 +62,7 @@ func TestService(t *testing.T) {
},
{
RefID: "B",
DataSource: DataSourceModel(),
DataSource: dataSourceModel(),
JSON: json.RawMessage(`{ "datasource": { "uid": "__expr__", "type": "__expr__"}, "type": "math", "expression": "$A * 2" }`),
},
}
@@ -124,3 +124,8 @@ func (me *mockEndpoint) QueryData(ctx context.Context, req *backend.QueryDataReq
}
return resp, nil
}
func dataSourceModel() *datasources.DataSource {
d, _ := DataSourceModelFromNodeType(TypeCMDNode)
return d
}