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

fix(http): fix /telegrafs panics when using org=org_name parameter #16527

Merged
merged 1 commit into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## v2.0.0-beta.2 [Unreleased]

### Bug Fixes

1. [16527](https://github.com/influxdata/influxdb/pull/16527): fix /telegrafs panics when using org=org_name parameter

### UI Improvements

1. [16203](https://github.com/influxdata/influxdb/pull/16203): Move cloud navigation to top of page instead of within left side navigation
Expand Down
2 changes: 1 addition & 1 deletion http/telegraf.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func decodeTelegrafConfigFilter(ctx context.Context, r *http.Request) (*platform
}
f.OrgID = orgID
} else if orgNameStr := q.Get("org"); orgNameStr != "" {
*f.Organization = orgNameStr
f.Organization = &orgNameStr
}
return f, err
}
Expand Down
42 changes: 42 additions & 0 deletions http/telegraf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,48 @@ func TestTelegrafHandler_handleGetTelegrafs(t *testing.T) {
}`,
},
},
{
name: "get telegraf configs by organization name",
r: httptest.NewRequest("GET", "http://any.url/api/v2/telegrafs?org=tc1", nil),
svc: &mock.TelegrafConfigStore{
FindTelegrafConfigsF: func(ctx context.Context, filter platform.TelegrafConfigFilter, opt ...platform.FindOptions) ([]*platform.TelegrafConfig, int, error) {
if filter.Organization != nil && *filter.Organization == "tc1" {
return []*platform.TelegrafConfig{
{
ID: platform.ID(1),
OrgID: platform.ID(2),
Name: "tc1",
Description: "",
Config: "[[inputs.cpu]]\n",
},
}, 1, nil
}

return []*platform.TelegrafConfig{}, 0, fmt.Errorf("not found")
},
},
wants: wants{
statusCode: http.StatusOK,
contentType: "application/json; charset=utf-8",
body: `{
"configurations": [
{
"id": "0000000000000001",
"orgID": "0000000000000002",
"name": "tc1",
"config": "[[inputs.cpu]]\n",
"labels": [],
"links": {
"self": "/api/v2/telegrafs/0000000000000001",
"labels": "/api/v2/telegrafs/0000000000000001/labels",
"members": "/api/v2/telegrafs/0000000000000001/members",
"owners": "/api/v2/telegrafs/0000000000000001/owners"
}
}
]
}`,
},
},
{
name: "return CPU plugin for telegraf",
r: httptest.NewRequest("GET", "http://any.url/api/v2/telegrafs", nil),
Expand Down