Chore: Unify references for dataquery (#68963)

* Unify references for dataquery

* Fix ResultFormat in azure types

* Update azure-log with new schema

* Fix cloudwatch query

* Update thema

* Fix test

* More fixes

* More fixes

* Fix lint
This commit is contained in:
Selene
2023-05-26 10:16:01 +02:00
committed by GitHub
parent 37c960e104
commit bd622a5381
19 changed files with 706 additions and 2330 deletions
@@ -9,12 +9,6 @@
package dataquery
// Defines values for EditorMode.
const (
EditorModeBuilder EditorMode = "builder"
EditorModeCode EditorMode = "code"
)
// Defines values for LokiQueryDirection.
const (
LokiQueryDirectionBackward LokiQueryDirection = "backward"
@@ -41,14 +35,44 @@ const (
SupportingQueryTypeLogsVolume SupportingQueryType = "logsVolume"
)
// LokiDataQuery defines model for LokiDataQuery.
type LokiDataQuery struct {
// These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
type DataQuery struct {
// For mixed data sources the selected datasource is on the query level.
// For non mixed scenarios this is undefined.
// TODO find a better way to do this ^ that's friendly to schema
// TODO this shouldn't be unknown but DataSourceRef | null
Datasource *interface{} `json:"datasource,omitempty"`
EditorMode *EditorMode `json:"editorMode,omitempty"`
// Hide true if query is disabled (ie should not be returned to the dashboard)
// Note this does not always imply that the query should not be executed since
// the results from a hidden query may be used as the input to other queries (SSE etc)
Hide *bool `json:"hide,omitempty"`
// Specify the query flavor
// TODO make this required and give it a default
QueryType *string `json:"queryType,omitempty"`
// A unique identifier for the query within the list of targets.
// In server side expressions, the refId is used as a variable name to identify results.
// By default, the UI will assign A->Z; however setting meaningful names may be useful.
RefId string `json:"refId"`
}
// LokiDataQuery defines model for LokiDataQuery.
type LokiDataQuery struct {
// DataQuery These are the common properties available to all queries in all datasources.
// Specific implementations will *extend* this interface, adding the required
// properties for the given context.
DataQuery
// For mixed data sources the selected datasource is on the query level.
// For non mixed scenarios this is undefined.
// TODO find a better way to do this ^ that's friendly to schema
// TODO this shouldn't be unknown but DataSourceRef | null
Datasource *interface{} `json:"datasource,omitempty"`
EditorMode *QueryEditorMode `json:"editorMode,omitempty"`
// The LogQL query.
Expr string `json:"expr"`
@@ -83,9 +107,6 @@ type LokiDataQuery struct {
Resolution *int64 `json:"resolution,omitempty"`
}
// EditorMode defines model for LokiDataQuery.EditorMode.
type EditorMode string
// LokiQueryDirection defines model for LokiQueryDirection.
type LokiQueryDirection string