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

Add FolderID to SetDashboard api request #67

Merged
merged 3 commits into from
Mar 26, 2020

Conversation

masudur-rahman
Copy link
Contributor

Signed-off-by: Masudur Rahman masud@appscode.com

@coveralls
Copy link

coveralls commented Feb 25, 2020

Coverage Status

Coverage increased (+0.3%) to 43.467% when pulling 04d9ecd on searchlight:add-folder-id into ebfd6e2 on grafana-tools:master.

Copy link
Collaborator

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR! Some suggestions in-line.

@@ -66,7 +66,7 @@ func main() {
continue
}
c.DeleteDashboard(board.UpdateSlug())
_, err := c.SetDashboard(board, false)
_, err := c.SetDashboard(board, 0, false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we convert 0 into a constant with a name like const GeneralFolderId = 0 so that it would be clearer what's going on?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I'll change that. Thanks

@@ -165,11 +165,12 @@ func (r *Client) SearchDashboards(query string, starred bool, tags ...string) ([
// may be only loaded with HTTP API but not created or updated.
//
// Reflects POST /api/dashboards/db API call.
func (r *Client) SetDashboard(board Board, overwrite bool) (StatusMessage, error) {
func (r *Client) SetDashboard(board Board, folderId int, overwrite bool) (StatusMessage, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets please avoid adding new parameters like that. Could you please add a type type SetDashboardParams func(values url.Values) just like in rest-annotation.go, convert this into a variadic function, and then iterate over them instead of adding this? We really want to avoid this.

rest-dashboard.go Show resolved Hide resolved
Signed-off-by: Masudur Rahman <masud@appscode.com>
Signed-off-by: Masudur Rahman <masud@appscode.com>
@masudur-rahman
Copy link
Contributor Author

Lets please avoid adding new parameters like that. Could you please add a type type SetDashboardParams func(values url.Values) just like in rest-annotation.go, convert this into a variadic function, and then iterate over them instead of adding this? We really want to avoid this.

@GiedriusS, we can't use func(values url.Values) here as SetDashboardParams because we need the params as request.Body instead of url query.

#67 (comment)

I think it will be a bit problem as we don't get FolderID in response of GetDasboard api.

Could you please check if the changes are okay ?

Copy link
Collaborator

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tough one to call. We want to avoid becoming a frankstein with a bunch of different calling conventions but IMHO this makes sense. The SetDashboard could potentially gain a bunch of different options into the future and we want to add new stuff without breaking existing users. It's a good middle ground solution between complete extensibility via interface{} but zero type-safety and listing all of the possible options explicitly in a function call.

Two requests in-line. Thanks for working on this!

rest-dashboard.go Show resolved Hide resolved
rest-dashboard.go Show resolved Hide resolved
Signed-off-by: Masudur Rahman <masud@appscode.com>
@masudur-rahman
Copy link
Contributor Author

Hey @GiedriusS, I have added the comment you suggested. Hope it's okay.

Copy link
Collaborator

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's see for a few days if anyone else has any comments before merging.

@masudur-rahman
Copy link
Contributor Author

LGTM, let's see for a few days if anyone else has any comments before merging.

okay

@GiedriusS GiedriusS merged commit 63c6c7e into grafana-tools:master Mar 26, 2020
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

3 participants