From a26b670fe02bc7d5d9a10b6f59a254b05d751229 Mon Sep 17 00:00:00 2001 From: Yi S Date: Mon, 27 Nov 2023 15:08:02 +0800 Subject: [PATCH] feat(admin-api): add gateway edition info to the endpoint `/` (#12097) This commit is the follow-up change to the PR https://github.com/Kong/kong/pull/12045, since the the edition info is still useful to the kong manager, we choose to introduce the gateway edition information in the response of the `/` endpoint. Fix FTI-5557 --- .../kong/add-gateway-edition-to-root-endpoint-admin-api.yml | 3 +++ kong/api/routes/kong.lua | 1 + spec/02-integration/04-admin_api/02-kong_routes_spec.lua | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/kong/add-gateway-edition-to-root-endpoint-admin-api.yml diff --git a/changelog/unreleased/kong/add-gateway-edition-to-root-endpoint-admin-api.yml b/changelog/unreleased/kong/add-gateway-edition-to-root-endpoint-admin-api.yml new file mode 100644 index 000000000000..a332be2ecced --- /dev/null +++ b/changelog/unreleased/kong/add-gateway-edition-to-root-endpoint-admin-api.yml @@ -0,0 +1,3 @@ +message: add gateway edition to the root endpoint of the admin api +type: feature +scope: Admin API diff --git a/kong/api/routes/kong.lua b/kong/api/routes/kong.lua index d7401c57f826..3cafb81cc83c 100644 --- a/kong/api/routes/kong.lua +++ b/kong/api/routes/kong.lua @@ -106,6 +106,7 @@ return { return kong.response.exit(200, { tagline = tagline, version = version, + edition = meta._VERSION:match("enterprise") and "enterprise" or "community", hostname = knode.get_hostname(), node_id = node_id, timers = { diff --git a/spec/02-integration/04-admin_api/02-kong_routes_spec.lua b/spec/02-integration/04-admin_api/02-kong_routes_spec.lua index 49d4e284f713..673c7f629967 100644 --- a/spec/02-integration/04-admin_api/02-kong_routes_spec.lua +++ b/spec/02-integration/04-admin_api/02-kong_routes_spec.lua @@ -69,7 +69,7 @@ describe("Admin API - Kong routes with strategy #" .. strategy, function() assert.not_nil(res.headers["X-Kong-Admin-Latency"]) end) - it("returns Kong's version number and tagline", function() + it("returns Kong's version number, edition info and tagline", function() local res = assert(client:send { method = "GET", path = "/" @@ -77,6 +77,7 @@ describe("Admin API - Kong routes with strategy #" .. strategy, function() local body = assert.res_status(200, res) local json = cjson.decode(body) assert.equal(meta._VERSION, json.version) + assert.equal(meta._VERSION:match("enterprise") and "enterprise" or "community", json.edition) assert.equal("Welcome to kong", json.tagline) end) it("returns a UUID as the node_id", function()