Skip to content
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

Support object-typed datasource references #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

colega
Copy link
Contributor

@colega colega commented Mar 4, 2022

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.

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]>
@safaci2000
Copy link
Contributor

safaci2000 commented Mar 15, 2022

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)

@colega
Copy link
Contributor Author

colega commented Mar 16, 2022

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 datasource field in other object, which was previously a string and now it's a an object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants