Merge pull request #16527 from oiooj/pr-panic

fix(http): fix /telegrafs panics when using org=org_name parameter
pull/16676/head
Jade McGough 2020-01-26 19:48:49 -08:00 committed by GitHub
commit e78be03465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 1 deletions

View File

@ -13,6 +13,10 @@
1. [16656](https://github.com/influxdata/influxdb/pull/16656): Check engine closed before collecting index metrics
1. [16412](https://github.com/influxdata/influxdb/pull/16412): Reject writes which use any of the reserved tag keys
### Bug Fixes
1. [16527](https://github.com/influxdata/influxdb/pull/16527): fix /telegrafs panics when using org=org_name parameter
### UI Improvements
1. [16575](https://github.com/influxdata/influxdb/pull/16575): Swap billingURL with checkoutURL

View File

@ -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
}

View File

@ -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),