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

Allow custom types for JSON/secure JSON data of plugins #84

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sd2k
Copy link
Collaborator

@sd2k sd2k commented Oct 13, 2022

This PR allows plugins to specify the concrete type of the
JSON/secure JSON data decoded into the PluginContext.instance_settings
field on incoming requests. They do so by implementing a new
GrafanaPlugin trait (which all plugins must now do); this is made
easier by using an identically named derive macro and specifying the
custom types as attributes.

@sd2k sd2k force-pushed the strongly-typed-json-data branch 3 times, most recently from 0b08020 to ad1dac4 Compare January 11, 2023 18:02
@sd2k sd2k changed the title Make plugin's JSON/secure JSON data strongly typed Allow custom types for JSON/secure JSON data of plugins Jan 11, 2023
@sd2k sd2k force-pushed the strongly-typed-json-data branch 2 times, most recently from 8dff6d8 to af5b2d1 Compare January 11, 2023 22:19
@sd2k sd2k marked this pull request as ready for review January 31, 2023 22:26
@sd2k sd2k force-pushed the strongly-typed-json-data branch 2 times, most recently from 07250f8 to 0c2ea22 Compare March 17, 2023 13:08
This commit allows plugins to specify the concrete type of the
JSON/secure JSON data decoded into the `PluginContext.instance_settings`
field on incoming requests. They do so by implementing a new
`GrafanaPlugin` trait (which all plugins must now do); this is made
easier by using an identically named derive macro and specifying the
custom types as attributes.
It turns out this can be optional if the request targets a datasource
but not a datasource instance.
This no longer works because the trait requires `GrafanaPlugin` as a supertrait
of the implementing type, unfortunately.
We should never return a tonic error, just convert any errors into
a string representation.
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.

None yet

1 participant