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(api-server): move -overview to _overview #8173

Merged
merged 1 commit into from
Oct 30, 2023
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
8 changes: 4 additions & 4 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ New rule is applied for CREATE operations. The old rule is still applied for UPD

These endpoints are getting replaced to achieve more coherency on the API:

- `/meshes/{mesh}/zoneegressoverviews` moves to `/meshes/{mesh}/zoneegresses/-overview`
- `/meshes/{mesh}/zoneingresses+insights` moves to `/meshes/{mesh}/zone-ingresses/-overview`
- `/meshes/{mesh}/dataplanes+insights` moves to `/meshes/{mesh}/dataplanes/-overview`
- `/zones+insights` moves to `/zones/-overview`
- `/meshes/{mesh}/zoneegressoverviews` moves to `/meshes/{mesh}/zoneegresses/_overview`
- `/meshes/{mesh}/zoneingresses+insights` moves to `/meshes/{mesh}/zone-ingresses/_overview`
- `/meshes/{mesh}/dataplanes+insights` moves to `/meshes/{mesh}/dataplanes/_overview`
- `/zones+insights` moves to `/zones/_overview`

While you can use the old API they will be removed in a future version

Expand Down
110 changes: 15 additions & 95 deletions pkg/api-server/dataplane_overview_endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,77 +126,6 @@ var _ = Describe("Dataplane Overview Endpoints", func() {
Expect(err).ToNot(HaveOccurred())
})

gatewayDelegatedJson := `
{
"type": "DataplaneOverview",
"name": "gateway-delegated",
"mesh": "mesh1",
"creationTime": "2018-07-17T16:05:36.995Z",
"modificationTime": "2018-07-17T16:05:36.995Z",
"dataplane": {
"networking": {
"address": "127.0.0.1",
"gateway": {
"tags": {
"service": "gateway"
}
}
}
},
"dataplaneInsight": {
"subscriptions": [
{
"id": "stream-id-1",
"controlPlaneInstanceId": "cp-1",
"connectTime": "2019-07-01T00:00:00Z",
"status": {
"total": {},
"cds": {},
"eds": {},
"lds": {},
"rds": {}
}
}
]
}
}`

gatewayBuiltinJson := `
{
"type": "DataplaneOverview",
"name": "gateway-builtin",
"mesh": "mesh1",
"creationTime": "2018-07-17T16:05:36.995Z",
"modificationTime": "2018-07-17T16:05:36.995Z",
"dataplane": {
"networking": {
"address": "127.0.0.1",
"gateway": {
"type": "BUILTIN",
"tags": {
"service": "gateway"
}
}
}
},
"dataplaneInsight": {
"subscriptions": [
{
"id": "stream-id-1",
"controlPlaneInstanceId": "cp-1",
"connectTime": "2019-07-01T00:00:00Z",
"status": {
"total": {},
"cds": {},
"eds": {},
"lds": {},
"rds": {}
}
}
]
}
}`

dp1Json := `
{
"type": "DataplaneOverview",
Expand Down Expand Up @@ -251,8 +180,7 @@ var _ = Describe("Dataplane Overview Endpoints", func() {
})

type testCase struct {
url string
expectedJson string
url string
}

DescribeTable("Listing resources filtering by tag",
Expand All @@ -275,48 +203,40 @@ var _ = Describe("Dataplane Overview Endpoints", func() {
Expect(body).To(matchers.MatchGoldenJSON("testdata", goldenFileName))
},
Entry("should list all when no tag is provided", testCase{
url: "meshes/mesh1/dataplanes+insights",
expectedJson: fmt.Sprintf(`{"total": 3, "items": [%s, %s, %s], "next": null}`, dp1Json, gatewayBuiltinJson, gatewayDelegatedJson),
url: "meshes/mesh1/dataplanes+insights",
}),
Entry("should list with only one matching tag", testCase{
url: "meshes/mesh1/dataplanes+insights?tag=service:backend",
expectedJson: fmt.Sprintf(`{"total": 1, "items": [%s], "next": null}`, dp1Json),
url: "meshes/mesh1/dataplanes+insights?tag=service:backend",
}),
Entry("should list with only subset tag", testCase{
url: "meshes/mesh1/dataplanes+insights?tag=service:ck",
expectedJson: fmt.Sprintf(`{"total": 1, "items": [%s], "next": null}`, dp1Json),
url: "meshes/mesh1/dataplanes+insights?tag=service:ck",
}),
Entry("should list all with all matching tags", testCase{
url: "meshes/mesh1/dataplanes+insights?tag=service:backend&tag=version:v1",
expectedJson: fmt.Sprintf(`{"total": 1, "items": [%s], "next": null}`, dp1Json),
url: "meshes/mesh1/dataplanes+insights?tag=service:backend&tag=version:v1",
}),
Entry("should list all with all matching tags with value with a column", testCase{
url: "meshes/mesh1/dataplanes+insights?tag=tagcolumn:tag:v",
expectedJson: fmt.Sprintf(`{"total": 1, "items": [%s], "next": null}`, dp1Json),
url: "meshes/mesh1/dataplanes+insights?tag=tagcolumn:tag:v",
}),
Entry("should not list when any tag is not matching", testCase{
url: "meshes/mesh1/dataplanes+insights?tag=service:backend&tag=version:v2",
expectedJson: `{"total": 0, "items": [], "next": null}`,
url: "meshes/mesh1/dataplanes+insights?tag=service:backend&tag=version:v2",
}),
Entry("should list only gateway dataplanes", testCase{
url: "meshes/mesh1/dataplanes+insights?gateway=true",
expectedJson: fmt.Sprintf(`{"total": 2, "items": [%s, %s], "next": null}`, gatewayBuiltinJson, gatewayDelegatedJson),
url: "meshes/mesh1/dataplanes+insights?gateway=true",
}),
Entry("should list only gateway builtin", testCase{
url: "meshes/mesh1/dataplanes+insights?gateway=builtin",
expectedJson: fmt.Sprintf(`{"total": 1, "items": [%s], "next": null}`, gatewayBuiltinJson),
url: "meshes/mesh1/dataplanes+insights?gateway=builtin",
}),
Entry("should list only gateway delegated", testCase{
url: "meshes/mesh1/dataplanes+insights?gateway=delegated",
expectedJson: fmt.Sprintf(`{"total": 1, "items": [%s], "next": null}`, gatewayDelegatedJson),
url: "meshes/mesh1/dataplanes+insights?gateway=delegated",
}),
Entry("should list only dataplanes that starts with gateway", testCase{
url: "meshes/mesh1/dataplanes+insights?name=gateway",
expectedJson: fmt.Sprintf(`{"total": 2, "items": [%s, %s], "next": null}`, gatewayBuiltinJson, gatewayDelegatedJson),
url: "meshes/mesh1/dataplanes+insights?name=gateway",
}),
Entry("should list only dataplanes that contains with tew", testCase{
url: "meshes/mesh1/dataplanes+insights?name=tew",
expectedJson: fmt.Sprintf(`{"total": 2, "items": [%s, %s], "next": null}`, gatewayBuiltinJson, gatewayDelegatedJson),
url: "meshes/mesh1/dataplanes+insights?name=tew",
}),
Entry("should list only dataplanes that contains with tew using _overview", testCase{
url: "meshes/mesh1/dataplanes/_overview?name=tew",
}),
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/api-server/resource_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (r *resourceEndpoints) addFindEndpoint(ws *restful.WebService, pathPrefix s
Returns(404, "Not found", nil))
if r.descriptor.HasInsights() {
route := r.findResource(true)
ws.Route(ws.GET(pathPrefix+"/{name}/-overview").To(route).
ws.Route(ws.GET(pathPrefix+"/{name}/_overview").To(route).
Doc(fmt.Sprintf("Get overview of a %s", r.descriptor.WsPath)).
Param(ws.PathParameter("name", fmt.Sprintf("Name of a %s", r.descriptor.Name)).DataType("string")).
Returns(200, "OK", nil).
Expand Down Expand Up @@ -150,7 +150,7 @@ func (r *resourceEndpoints) addListEndpoint(ws *restful.WebService, pathPrefix s
Returns(200, "OK", nil))
if r.descriptor.HasInsights() {
route := r.listResources(true)
ws.Route(ws.GET(pathPrefix+"/-overview").To(route).
ws.Route(ws.GET(pathPrefix+"/_overview").To(route).
Doc(fmt.Sprintf("Get a %s", r.descriptor.WsPath)).
Param(ws.QueryParameter("size", "size of page").DataType("int")).
Param(ws.QueryParameter("offset", "offset of page to list").DataType("string")).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"total": 2,
"items": [
{
"type": "DataplaneOverview",
"mesh": "mesh1",
"name": "gateway-builtin",
"creationTime": "2018-07-17T16:05:36.995Z",
"modificationTime": "2018-07-17T16:05:36.995Z",
"dataplane": {
"networking": {
"address": "127.0.0.1",
"gateway": {
"tags": {
"service": "gateway"
},
"type": "BUILTIN"
}
}
},
"dataplaneInsight": {
"subscriptions": [
{
"id": "stream-id-1",
"controlPlaneInstanceId": "cp-1",
"connectTime": "2019-07-01T00:00:00Z",
"status": {
"total": {},
"cds": {},
"eds": {},
"lds": {},
"rds": {}
}
}
]
}
},
{
"type": "DataplaneOverview",
"mesh": "mesh1",
"name": "gateway-delegated",
"creationTime": "2018-07-17T16:05:36.995Z",
"modificationTime": "2018-07-17T16:05:36.995Z",
"dataplane": {
"networking": {
"address": "127.0.0.1",
"gateway": {
"tags": {
"service": "gateway"
}
}
}
},
"dataplaneInsight": {
"subscriptions": [
{
"id": "stream-id-1",
"controlPlaneInstanceId": "cp-1",
"connectTime": "2019-07-01T00:00:00Z",
"status": {
"total": {},
"cds": {},
"eds": {},
"lds": {},
"rds": {}
}
}
]
}
}
],
"next": null
}