-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Dashboard: Replace datasource name with a reference object #33817
Conversation
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.
This looks very promising, awesome job
I assume that this introduces a new schema version, and that older schema versions will be migrated to this version. In which case, at least in this sense, this isn't a breaking change. Existing dashboard json will continue to work. It will only break if you update the schema version without updating your dashboard references. Are these assumptions correct? |
@@ -62,7 +65,7 @@ export class DashboardMigrator { | |||
let i, j, k, n; | |||
const oldVersion = this.dashboard.schemaVersion; | |||
const panelUpgrades: PanelSchemeUpgradeHandler[] = []; | |||
this.dashboard.schemaVersion = 32; | |||
this.dashboard.schemaVersion = 33; |
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.
@malcolmholmes this changes the schemaVersion
Very great idea, thank you very mich for this improvment |
I removed the breaking change label for now. |
See: grafana/grafana#33817 Since Grafana v8.4.3 datasource references are not longer a string with the datasource name, but an object with the type and UID instead. This means that dashboards saved with Grafana v8.4.3 or higher are not longer parseable by this SDK. I replaced the `*string` datasource by a `DatasourceRef` struct, which has custom unmarshaling: it tries to unmarshal the new object, and if it fails, it will try to unmarshal data as string and put it into `LegacyName` instead. Signed-off-by: Oleg Zaytsev <[email protected]>
Fixes #1664, See also #32853
We currently store the datasource name in the dashboard, this has a few bad effects:
This replaces our existing string object with a datasourceRef:
Although we could simply replace our existing name with the uid, using an object with type makes defining dashboards programatically MUCH more natural. Specifically, this allows us to day "I need a loki datasource, but I don't care which one". Also the type parameter will allow validating the query syntax without without needing to lookup
uid
>datasource.pluginType
TODO: