refactor: change how grafana plugins are installed#211
Open
refactor: change how grafana plugins are installed#211
Conversation
droguljic
requested changes
May 11, 2026
Comment on lines
+4
to
+7
| type PluginReadyInputs = { | ||
| grafanaToken: pulumi.Input<string>; | ||
| pluginSlug: string; | ||
| }; |
Contributor
There was a problem hiding this comment.
Why not export namespace PluginReady { export type Args = { ... } }?
Comment on lines
+13
to
+20
| const grafanaConfig = new pulumi.Config('grafana'); | ||
| const grafanaUrl = grafanaConfig.get('url') ?? process.env.GRAFANA_URL; | ||
|
|
||
| if (!grafanaUrl) { | ||
| throw new Error( | ||
| 'Grafana URL is not configured. Set it via Pulumi config (grafana:url) or GRAFANA_URL env var.', | ||
| ); | ||
| } |
Contributor
There was a problem hiding this comment.
We are already doing this validation inside of Grafana component. No need for duplication; just pass the Grafana URL as a parameter.
| ); | ||
| } | ||
|
|
||
| const url = `${grafanaUrl.replace(/\/$/, '')}/api/plugins/${pluginSlug}/settings`; |
Contributor
There was a problem hiding this comment.
Use the URL,
const url = (new URL(`/api/plugins/${pluginSlug}/settings`, grafanaUrl)).href;
Comment on lines
+24
to
+43
| for (let attempt = 0; attempt < 60; attempt++) { | ||
| const { statusCode, body } = await request(url, { | ||
| method: 'GET', | ||
| headers: { | ||
| Authorization: `Bearer ${grafanaToken}`, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }); | ||
|
|
||
| if (statusCode === 200) { | ||
| const data = (await body.json()) as { id: string }; | ||
| return { id: data.id, outs: {} }; | ||
| } | ||
|
|
||
| if (statusCode !== 404) { | ||
| throw new Error('Unexpected error'); | ||
| } | ||
|
|
||
| await new Promise(r => setTimeout(r, 5000)); | ||
| } |
Contributor
There was a problem hiding this comment.
Use the exponential backOff library with the cap for max wait time.
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.
No description provided.