Try to get targetspec change to stick
This commit is contained in:
@@ -31,23 +31,11 @@ ConfigSpec: {
|
||||
transformations?: [...TransformationSpec]
|
||||
}
|
||||
|
||||
/*todo this is incorrect - target needs to be an object with any sort of key/value combination
|
||||
inside of it
|
||||
for external correlations, this is just `target: { url: 'google.com' }` ,
|
||||
but for query correlations, target is the json for populating the query editor, which is different
|
||||
for every datasource
|
||||
|
||||
right now this is resolving to require an object of objects, like item.spec.config.target.url is expecting an object
|
||||
instead of a string. how do i fix this?
|
||||
|
||||
Already tried and unsuccessful
|
||||
TargetSpec: [string]: _
|
||||
|
||||
*/
|
||||
TargetSpec: {
|
||||
[string]: _
|
||||
TargetSpec: {
|
||||
test: string
|
||||
}
|
||||
|
||||
|
||||
TransformationSpec: {
|
||||
type: "regex" | "logfmt"
|
||||
expression: string
|
||||
|
||||
@@ -33,11 +33,20 @@ type CorrelationConfigSpec struct {
|
||||
|
||||
// NewCorrelationConfigSpec creates a new CorrelationConfigSpec object.
|
||||
func NewCorrelationConfigSpec() *CorrelationConfigSpec {
|
||||
return &CorrelationConfigSpec{}
|
||||
return &CorrelationConfigSpec{
|
||||
Target: *NewCorrelationTargetSpec(),
|
||||
}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CorrelationTargetSpec map[string]interface{}
|
||||
type CorrelationTargetSpec struct {
|
||||
Test string `json:"test"`
|
||||
}
|
||||
|
||||
// NewCorrelationTargetSpec creates a new CorrelationTargetSpec object.
|
||||
func NewCorrelationTargetSpec() *CorrelationTargetSpec {
|
||||
return &CorrelationTargetSpec{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CorrelationTransformationSpec struct {
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
rawSchemaCorrelationv0alpha1 = []byte(`{"ConfigSpec":{"additionalProperties":false,"description":"there was a deprecated field here called type, we will need to move that for conversion and provisioning","properties":{"field":{"type":"string"},"target":{"$ref":"#/components/schemas/TargetSpec"},"transformations":{"items":{"$ref":"#/components/schemas/TransformationSpec"},"type":"array"}},"required":["field","target"],"type":"object"},"Correlation":{"properties":{"spec":{"$ref":"#/components/schemas/spec"}},"required":["spec"]},"CorrelationType":{"enum":["query","external"],"type":"string"},"DataSourceRef":{"additionalProperties":false,"properties":{"group":{"description":"same as pluginId","type":"string"},"name":{"description":"same as grafana uid","type":"string"}},"required":["group","name"],"type":"object"},"TargetSpec":{"additionalProperties":{"additionalProperties":{},"type":"object"},"type":"object"},"TransformationSpec":{"additionalProperties":false,"properties":{"expression":{"type":"string"},"field":{"type":"string"},"mapValue":{"type":"string"},"type":{"enum":["regex","logfmt"],"type":"string"}},"required":["type","expression","field","mapValue"],"type":"object"},"spec":{"additionalProperties":false,"properties":{"config":{"$ref":"#/components/schemas/ConfigSpec"},"description":{"type":"string"},"label":{"type":"string"},"source":{"$ref":"#/components/schemas/DataSourceRef"},"target":{"$ref":"#/components/schemas/DataSourceRef"},"type":{"$ref":"#/components/schemas/CorrelationType"}},"required":["type","source","label","config"],"type":"object"}}`)
|
||||
rawSchemaCorrelationv0alpha1 = []byte(`{"ConfigSpec":{"additionalProperties":false,"description":"there was a deprecated field here called type, we will need to move that for conversion and provisioning","properties":{"field":{"type":"string"},"target":{"$ref":"#/components/schemas/TargetSpec"},"transformations":{"items":{"$ref":"#/components/schemas/TransformationSpec"},"type":"array"}},"required":["field","target"],"type":"object"},"Correlation":{"properties":{"spec":{"$ref":"#/components/schemas/spec"}},"required":["spec"]},"CorrelationType":{"enum":["query","external"],"type":"string"},"DataSourceRef":{"additionalProperties":false,"properties":{"group":{"description":"same as pluginId","type":"string"},"name":{"description":"same as grafana uid","type":"string"}},"required":["group","name"],"type":"object"},"TargetSpec":{"additionalProperties":false,"properties":{"test":{"type":"string"}},"required":["test"],"type":"object"},"TransformationSpec":{"additionalProperties":false,"properties":{"expression":{"type":"string"},"field":{"type":"string"},"mapValue":{"type":"string"},"type":{"enum":["regex","logfmt"],"type":"string"}},"required":["type","expression","field","mapValue"],"type":"object"},"spec":{"additionalProperties":false,"properties":{"config":{"$ref":"#/components/schemas/ConfigSpec"},"description":{"type":"string"},"label":{"type":"string"},"source":{"$ref":"#/components/schemas/DataSourceRef"},"target":{"$ref":"#/components/schemas/DataSourceRef"},"type":{"$ref":"#/components/schemas/CorrelationType"}},"required":["type","source","label","config"],"type":"object"}}`)
|
||||
versionSchemaCorrelationv0alpha1 app.VersionSchema
|
||||
_ = json.Unmarshal(rawSchemaCorrelationv0alpha1, &versionSchemaCorrelationv0alpha1)
|
||||
)
|
||||
|
||||
+6
-2
@@ -31,9 +31,13 @@ export const defaultConfigSpec = (): ConfigSpec => ({
|
||||
target: defaultTargetSpec(),
|
||||
});
|
||||
|
||||
export type TargetSpec = Record<string, any>;
|
||||
export interface TargetSpec {
|
||||
test: string;
|
||||
}
|
||||
|
||||
export const defaultTargetSpec = (): TargetSpec => ({});
|
||||
export const defaultTargetSpec = (): TargetSpec => ({
|
||||
test: "",
|
||||
});
|
||||
|
||||
export interface TransformationSpec {
|
||||
type: "regex" | "logfmt";
|
||||
|
||||
-6
@@ -407,12 +407,6 @@ export type ObjectMeta = {
|
||||
Populated by the system. Read-only. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids */
|
||||
uid?: string;
|
||||
};
|
||||
|
||||
/*
|
||||
this needs to be
|
||||
[key: string]: any;
|
||||
};
|
||||
*/
|
||||
export type CorrelationTargetSpec = {
|
||||
[key: string]: {
|
||||
[key: string]: any;
|
||||
|
||||
@@ -88,8 +88,8 @@ func ToSpecConfig(orig CorrelationConfig) (*correlationsV0.CorrelationConfigSpec
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(out.Target) == 0 {
|
||||
out.Target = nil
|
||||
if len(out.Target.Test) == 0 {
|
||||
out.Target.Test = "hi"
|
||||
}
|
||||
return out, err
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func ToConfig(orig correlationsV0.CorrelationConfigSpec) (*CorrelationConfig, er
|
||||
return nil, err
|
||||
}
|
||||
if len(out.Target) == 0 {
|
||||
out.Target = nil
|
||||
out.Target = map[string]any{}
|
||||
}
|
||||
return out, err
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func TestIntegrationCorrelations(t *testing.T) {
|
||||
Type: correlations.CorrelationType("query"),
|
||||
Config: correlations.CorrelationConfig{
|
||||
Field: "a",
|
||||
Target: map[string]any{},
|
||||
Target: map[string]any{ "test": "hi"},
|
||||
Transformations: correlations.Transformations{{
|
||||
Type: "logfmt",
|
||||
Expression: "aaaa",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -110,7 +110,7 @@ const toEnrichedCorrelationDataK8s = (item: CorrelationK8s): CorrelationData | u
|
||||
config: {
|
||||
field: item.spec.config.field,
|
||||
target: {
|
||||
url: item.spec.config.target.url || '', // todo this is wrong, fix in spec
|
||||
url: item.spec.config.target.url.url || '', // todo this is wrong, fix in spec
|
||||
},
|
||||
transformations: [], // todo fix
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user