-
Notifications
You must be signed in to change notification settings - Fork 69
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
Analyse grafana: Use minimal schema #247
Conversation
@@ -0,0 +1,36 @@ | |||
package analyse |
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.
I would write a comment in this mentioning the purpose of these (same thing you wrote on the PR description) to avoid someone coming and completing it with all fields.
} | ||
Target struct { | ||
RefID string `json:"refId"` | ||
Datasource string `json:"datasource,omitempty"` |
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.
This will not parse modern dashboards, where this is an object. So we still need either #239 or my change from grafana-tools/sdk#201
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.
Ah I don't think this field actually gets used anywhere at the moment, so i could remove it.
However if we fork, I agree that it makes more sense to just use the fork instead of the above approach.
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.
I have a fork at https://github.com/colega/grafana-tools-sdk which you can use here as go mod replacement if you need, I've been merging all the fixes into master there.
continue | ||
} | ||
|
||
if err = json.Unmarshal(rawBoard, &board); err != nil { |
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.
Nit:
if err = json.Unmarshal(rawBoard, &board); err != nil { | |
if err := json.Unmarshal(rawBoard, &board); err != nil { |
Even if the outcome is the same, we don't really want to modify the outer err
variable.
if err != nil { | ||
return err | ||
} | ||
|
||
for _, link := range boardLinks { | ||
board, _, err := c.GetDashboardByUID(ctx, link.UID) | ||
rawBoard, _, err = c.GetRawDashboardBySlug(ctx, link.URI) |
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.
Nit: I'd keep :=
here.
Closing in favor of #248 |
* Update Helm release memcached to v5.15.8 Signed-off-by: Renovate Bot <[email protected]> * add changelog entry for dependency update Signed-off-by: ShuzZzle <[email protected]> Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: ShuzZzle <[email protected]>
The upstream sdk library is now quite out of sync with Grafana and is infrequently updated (as is this tool), and this often results in deserialization errors and breakage (e.g. https://github.com/grafana/support-escalations/issues/2089)
This PR adds a minimal schema which preserves existing functionality of the tool while avoiding all of the data structures and fields not necessary to its functionality. I think it will make this easier to maintain and avoids forking the
sdk
library.Deserialization additionally tested on kubernetes-mixin. There are also two dashboards included in unit tests.
Closes #241
Deprecates #239
cc @eamonryan @rgeyer