-
Notifications
You must be signed in to change notification settings - Fork 12.8k
FEATURE BRANCH: Add v2alpha2
api version: Consolidate schema breaking changes
#108172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
v2alpha2
api version: Consolidate schema breaking changes
* Use v2alpha2 by default * Apply only DS changes to alpha2 * Use v2alpha2 by default except to query * Create a v2 index in @grafana/schema * Update path and apply lint * Update tests
… variable (#108237) * Schema v2: Introduce group/datasource convention to GroupBy and AdHoc variables * add conversion * App Installer: Authorizer support (#108419) * Chore: use `satisfies` and remove a load of `any`s (#108397) use satisfies and remove a load of anys * improve logging and fail unified-storage migration with more than 0 errors (#108471) improve logging and fail unified-storage migration with more than 0 errors * fix conversion test * Secrets: Create more granular fixed roles for SecureValues (#108382) * Provisioning: Fix bug in job progress recording (#108440) Fix bug in job progress recording * Provisioning: Fix ImportAllPanelsFromLocalRepository test (#108441) * Provisioning: Skip flaky test * Fix flaky provisioning test * Fix lint --------- Co-authored-by: Roberto Jimenez Sanchez <[email protected]> * BulkDeleteProvisionedResource: Move progress bar into a second step (#108417) * Move progress bar into a second step --------- Co-authored-by: Alex Khomenko <[email protected]> * [Dashboard Schema Codegen] Move dashboard CUE codegen block back up into kind body (#108476) [Dashboard Schema Codegen] Move dashboard CUE codegen block back up into kind body to make sure new versions have the same settings. --------- Co-authored-by: Haris Rozajac <[email protected]> Co-authored-by: Todd Treece <[email protected]> Co-authored-by: Ashley Harrison <[email protected]> Co-authored-by: Will Assis <[email protected]> Co-authored-by: Matheus Macabu <[email protected]> Co-authored-by: Roberto Jiménez Sánchez <[email protected]> Co-authored-by: Roberto Jimenez Sanchez <[email protected]> Co-authored-by: Yunwen Zheng <[email protected]> Co-authored-by: Alex Khomenko <[email protected]> Co-authored-by: Austin Pond <[email protected]> Co-authored-by: Ivan Ortega <[email protected]>
…onvention (#108148) * Dashboards API: Register v2alpha2 API * Prepare conversion functions * Fix test * Refactor VizConfigKind to follow DataQueryKind convention * fix tests * use new dataquerykind convention alpha 2 * add conversion * fix tests * fix tests * fix another test * Fix merge --------- Co-authored-by: Dominik Prokop <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove unnecessary changes from other apps/* and code-wise looks good to me!
apps/alerting/notifications/pkg/apis/alerting/v0alpha1/receiver_schema_gen.go
Outdated
Show resolved
Hide resolved
"variables": [ | ||
null, | ||
null, | ||
null, | ||
null | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no conversions for variables!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivanortegaalba - just pushed these :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for the v2alpha2
API version by consolidating schema breaking changes. The main purpose is to update all imports and references from v2alpha1
to v2alpha2
throughout the codebase, while also implementing structural changes to better organize data queries and visualization configurations.
Key changes include:
- Migration from
v2alpha1
tov2alpha2
API version across all files - Restructuring of data query schema to use a more consistent
DataQuery
pattern withgroup
anddatasource
properties - Refactoring of visualization configuration to separate plugin metadata from configuration data
Reviewed Changes
Copilot reviewed 107 out of 107 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
packages/grafana-schema/src/schema/dashboard/v2alpha2/types.spec.gen.ts | New schema definition for v2alpha2 with restructured data queries and viz config |
packages/grafana-schema/src/schema/dashboard/v2.ts | Updated export path to point to v2alpha2 |
public/app/features/dashboard/api/v2.ts | Updated API version constant from v2alpha1 to v2alpha2 |
Multiple test files | Updated API version references and test data structures |
Multiple transformation files | Updated to handle new data query structure with group/datasource pattern |
enable: boolean; | ||
hide: boolean; | ||
iconColor: string; | ||
name: string; | ||
builtIn?: boolean; | ||
filter?: AnnotationPanelFilter; | ||
// Catch-all field for datasource-specific properties | ||
// Catch-all field for datasource-specific properties. Should not be available in as code tooling. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states this field 'should not be available in as code tooling' but doesn't explain why or provide guidance on alternatives. Consider expanding this comment to explain the intended use case and provide clearer guidance.
// Catch-all field for datasource-specific properties. Should not be available in as code tooling. | |
// Catch-all field for datasource-specific properties. This field is intended for internal use by datasources | |
// to store configuration options that are not part of the standard schema. It should not be available in | |
// "as code" tooling because its structure is highly dynamic and specific to individual datasources, making | |
// it unsuitable for validation or code generation. Developers should avoid relying on this field in generic | |
// tooling and instead use well-defined schema fields whenever possible. |
Copilot uses AI. Check for mistakes.
console.error( | ||
'Misconfigured AnnotationsDataLayer: Data source is required for annotations. Resolving default data source', | ||
layer, | ||
layerDs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using console.error directly in production code is not recommended. Consider using a proper logging framework or service that can be configured for different environments.
console.error( | |
'Misconfigured AnnotationsDataLayer: Data source is required for annotations. Resolving default data source', | |
layer, | |
layerDs | |
const logger = getLogger('transformSceneToSaveModelSchemaV2'); | |
logger.error( | |
'Misconfigured AnnotationsDataLayer: Data source is required for annotations. Resolving default data source', | |
{ layer, layerDs } |
Copilot uses AI. Check for mistakes.
@@ -257,14 +266,22 @@ function getDataSourceForQuery( | |||
}; | |||
} | |||
|
|||
// If we don't find a default datasource, return undefined | |||
return undefined; | |||
if (dsList && !dsList[defaultDatasource]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition checks if dsList
exists but then accesses dsList[defaultDatasource]
without verifying that defaultDatasource
is defined. This could throw an error if defaultDatasource
is undefined or null.
Copilot uses AI. Check for mistakes.
if (!dataQuery.datasource?.name) { | ||
delete dataQuery.datasource; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for handling missing datasource names appears in multiple places. Consider extracting this into a utility function to reduce code duplication and improve maintainability.
if (!dataQuery.datasource?.name) { | |
delete dataQuery.datasource; | |
} | |
const sanitizedDataQuery = sanitizeDatasource(dataQuery); |
Copilot uses AI. Check for mistakes.
Includes:
Fixes #108127