-
Notifications
You must be signed in to change notification settings - Fork 60
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
Handler middlewares #1019
Handler middlewares #1019
Conversation
70d3460
to
78d7342
Compare
78d7342
to
14a76a5
Compare
14a76a5
to
b528ab5
Compare
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.
LGTM, just some questions / nits
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.
Looks good - just one thing that is missing AFAICT
ctx = initErrorSource(ctx) | ||
ctx = WithEndpoint(ctx, endpoint) | ||
ctx = WithPluginContext(ctx, pluginCtx) | ||
ctx = WithGrafanaConfig(ctx, pluginCtx.GrafanaConfig) |
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.
It's only now when looking at all this when I realize all we really need to pass through for a lot of these is pluginCtx
since these are all exported fields that could be read as needed 🤦
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.
Yeah 😄 What do you suggest, remove WithGrafanaConfig
and use PluginConfigFromContext
in GrafanaConfigFromContext
? Or remove GrafanaConfigFromContext
altogether?
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.
If we remove WithGrafanaConfig
it'll break Grafana core - and all the core plugins would need to be updated.
Removing GrafanaConfigFromContext
will smash a bunch of plugins in the wild.
So I guess for now we do nothing, except cry 😢
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.
Yeah 😄 On the positive side, the current way allow tests to use backend. WithGrafanaConfig
rather than creating a full context.
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
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.
LGTM
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.
🚀
Moves https://github.com/grafana/grafana/blob/22df2d9b06b0b3651dcd1d2c075ffd48071ab556/pkg/plugins/ifaces.go#L137-L152 into the SDK.
At first I wanted to create a new
handlermiddleware
or similar package, but it would depend on the backend package and soon (follow up) the backend package is going to make use of handler middlewares and if so create a cyclic dependency 😢Implemented/used in grafana/grafana#93445
One breaking change renaming a constant (why
Detect incompatible changes
fails), but is related to experimental code and shouldn't affect plugins: