Correlations: Migrate config type to root (#91855)

* WIP

* Validate new field, and add value in provisioning if not defined in correct spot

* Simplify logic, use correct value

* fix tests

* Fix linter errors

* fix swagger and tests

* 😬

* Auto-generation isnt doing this..

* Fix linter

* test if nullable is the issue…

* Change structure on the frontend fields

* Try with backtick

* try programatic quoting

* Try only quote non-ints

* quoting, no backticks

* Remove debugging
This commit is contained in:
Kristina
2024-08-26 08:02:48 -05:00
committed by GitHub
parent 84e5c3af22
commit 1dd830b9f1
21 changed files with 114 additions and 113 deletions
@@ -115,8 +115,8 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", "nonexistent-ds-uid"),
body: fmt.Sprintf(`{
"targetUID": "%s",
"type": "query",
"config": {
"type": "query",
"field": "message",
"target": {}
}
@@ -137,13 +137,13 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
require.NoError(t, res.Body.Close())
})
t.Run("inexistent target data source should result in a 404 if config.type=query", func(t *testing.T) {
t.Run("inexistent target data source should result in a 404 if type=query", func(t *testing.T) {
res := ctx.Post(PostParams{
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", writableDs),
body: `{
"targetUID": "nonexistent-uid-uid",
"type": "query",
"config": {
"type": "query",
"field": "message",
"target": {}
}
@@ -169,8 +169,8 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", readOnlyDS),
body: fmt.Sprintf(`{
"targetUID": "%s",
"type": "query",
"config": {
"type": "query",
"field": "message",
"target": {}
}
@@ -200,8 +200,8 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", writableDs),
body: fmt.Sprintf(`{
"targetUID": "%s",
"type": "query",
"config": {
"type": "query",
"field": "message",
"target": {}
}
@@ -230,7 +230,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
description := "a description"
label := "a label"
fieldName := "fieldName"
configType := correlations.ConfigTypeQuery
corrType := correlations.TypeQuery
transformation := correlations.Transformation{Type: "logfmt"}
transformation2 := correlations.Transformation{Type: "regex", Expression: "testExpression", MapValue: "testVar"}
res := ctx.Post(PostParams{
@@ -239,8 +239,8 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
"targetUID": "%s",
"description": "%s",
"label": "%s",
"type": "%s",
"config": {
"type": "%s",
"field": "%s",
"target": { "expr": "foo" },
"transformations": [
@@ -248,7 +248,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
{"type": "regex", "expression": "testExpression", "mapValue": "testVar"}
]
}
}`, writableDs, description, label, configType, fieldName),
}`, writableDs, description, label, corrType, fieldName),
user: adminUser,
})
require.Equal(t, http.StatusOK, res.StatusCode)
@@ -265,7 +265,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
require.Equal(t, writableDs, *response.Result.TargetUID)
require.Equal(t, description, response.Result.Description)
require.Equal(t, label, response.Result.Label)
require.Equal(t, configType, response.Result.Config.Type)
require.Equal(t, corrType, response.Result.Type)
require.Equal(t, fieldName, response.Result.Config.Field)
require.Equal(t, map[string]any{"expr": "foo"}, response.Result.Config.Target)
require.Equal(t, transformation, response.Result.Config.Transformations[0])
@@ -39,7 +39,7 @@ func TestIntegrationCreateOrUpdateCorrelation(t *testing.T) {
OrgId: dataSource.OrgID,
Label: "needs migration",
Config: correlations.CorrelationConfig{
Type: correlations.ConfigTypeQuery,
Type: correlations.TypeQuery,
Field: "foo",
Target: map[string]any{},
Transformations: []correlations.Transformation{
@@ -55,7 +55,7 @@ func TestIntegrationCreateOrUpdateCorrelation(t *testing.T) {
OrgId: dataSource.OrgID,
Label: "existing",
Config: correlations.CorrelationConfig{
Type: correlations.ConfigTypeQuery,
Type: correlations.TypeQuery,
Field: "foo",
Target: map[string]any{},
Transformations: []correlations.Transformation{
@@ -77,8 +77,8 @@ func TestIntegrationReadCorrelation(t *testing.T) {
SourceUID: dsWithCorrelations.UID,
TargetUID: &dsWithCorrelations.UID,
OrgId: dsWithCorrelations.OrgID,
Type: correlations.TypeQuery,
Config: correlations.CorrelationConfig{
Type: correlations.ConfigTypeQuery,
Field: "foo",
Target: map[string]any{},
Transformations: []correlations.Transformation{
@@ -263,9 +263,9 @@ func TestIntegrationUpdateCorrelation(t *testing.T) {
body: `{
"label": "1",
"description": "1",
"type": "query",
"config": {
"field": "field",
"type": "query",
"target": { "expr": "bar" },
"transformations": [ {"type": "logfmt"} ]
}