Support object-typed datasource references#201
Open
colega wants to merge 1 commit intografana-tools:masterfrom
Open
Support object-typed datasource references#201colega wants to merge 1 commit intografana-tools:masterfrom
colega wants to merge 1 commit intografana-tools:masterfrom
Conversation
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 <mail@olegzaytsev.com>
Contributor
|
I had a similar request pending. https://github.com/grafana-tools/sdk/pull/195/files That fixed the issue for me. All you need is the Uid to be persisted when importing/exporting dashboards. That being said, I'm using the Raw calls rather the model maybe that's the big difference? More context here: esnet/gdg#71 (GDG is the tool i wrote to manage dashboards that utilizes this SDK) |
Contributor
Author
|
Hi! Note that #195 just adds more fields to the datasource object, so it won't prevent it from being unmarshaled (by this tool, IDK about grafana, which may will fail if there's no UID) This PR doesn't change the dastasource object definition, instead it changes the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
*stringdatasource by aDatasourceRefstruct, 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 intoLegacyNameinstead.