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

feature: new data model first steps (Routes & Services) #3224

Merged
merged 69 commits into from
Feb 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
cd748a3
feat(schema) new schema validation engine
hishamhm Oct 25, 2017
39d9e5e
feat(schema) adds schemas for routes and services
hishamhm Oct 25, 2017
87ad4c4
feat(db.errors) add new DB errors module
thibaultcha Oct 25, 2017
f771ed5
feat(db) add new DB modules and strategies skeleton
thibaultcha Oct 25, 2017
bd25321
feat(db) add 'fake' strategy
kikito Oct 25, 2017
4cbc359
feat(db) add 'postgres' strategy
bungle Oct 25, 2017
74c3373
feat(db) implement 'cassandra' strategy
thibaultcha Oct 25, 2017
3658253
feat(dao) add new DB entities migrations to old DAO
thibaultcha Oct 25, 2017
317416f
feat(tests-helpers) add the 'blueprints' module for tests fixtures
kikito Oct 26, 2017
775e544
tests(oauth2) use blueprints for fixtures declaration
kikito Oct 26, 2017
a79c831
feat(core) introduce the 'db' value in singletons
thibaultcha Oct 26, 2017
1888458
feat(admin) new '/routes' and '/services' endpoints
kikito Oct 26, 2017
2692eac
feat(admin) better form-urlencoded support for arrays in Admin API
thibaultcha Oct 26, 2017
da519f4
feat(db) generic strategy paging for foreign key methods
bungle Oct 26, 2017
064efd9
chore(rockspec) add kong.db and new admin api files to .rockspec
bungle Oct 26, 2017
a77ad9a
tests(spec_helpers) disable arrays encoding test
thibaultcha Oct 27, 2017
ac23f45
feat(admin) hashes are encoded in form-url-params
kikito Oct 31, 2017
8545466
feat(dao) implement service_id/route_id for Plugins
thibaultcha Nov 1, 2017
752ee12
feat(router) update router to use kong.db Routes and Services
bungle Oct 31, 2017
d9399b0
feat(plugins-iterator) implement iterator based on route and service …
bungle Nov 3, 2017
c89fa91
fix(db) init connector in init_by_lua (fixes Cassandra)
thibaultcha Nov 10, 2017
14ee5b3
refactor(handler) index protocols by their values
hishamhm Nov 13, 2017
232abe8
feat(db) cache and rebuild router based on Route/Service CRUD operations
thibaultcha Nov 14, 2017
64463d7
tests(integration) fix test suites left broken by Routes and Services…
bungle Nov 6, 2017
4214aaf
feat(db) add post_processing step and use Set metatable
kikito Nov 15, 2017
50980bd
feat(model) ensure json encoding of arrays as json arrays [] and neve…
bungle Jan 15, 2018
b45b4de
tests(plugins) fix tests left broken by routes and services model cha…
bungle Nov 8, 2017
b603596
feat(dao) delete cluster_events/routes/services tables during migrations
thibaultcha Nov 20, 2017
38b9ea0
chore(travis) drop testing on C* 2.x
thibaultcha Jan 15, 2018
5de5803
fix(model) postgres strategy uses timestamp with time zone now instea…
bungle Nov 15, 2017
def201f
feat(plugins) convert plugins to routes & services
kikito Nov 28, 2017
48e8ca6
feat(db) add routes:for_service() support to Cassandra strategy
thibaultcha Nov 29, 2017
3f24f02
fix(db) make routes:for_service() work with Postgres strategy
bungle Nov 29, 2017
2a93664
feat(db) sugar method to specify a Service scheme, host, port, and pa…
bungle Nov 30, 2017
aa41eb0
feat(admin-api) polish our handling of admin api parameters
bungle Dec 13, 2017
1661e55
feat(schema) add support for `unique = true` field
hishamhm Jan 4, 2018
dcc8cf9
feat(schema) mark services.name as unique
hishamhm Jan 4, 2018
e45c92e
feat(db) implement postgres strategy and errors support for unique co…
bungle Jan 5, 2018
41e3848
feat(api) handle new DAO error messages with appropriate status codes
bungle Jan 5, 2018
eeadcbe
feat(db) improve new error messages verbosity
kikito Jan 4, 2018
4ab8dc0
feat(db) implement UNIQUE constraint check in C* strategy
thibaultcha Jan 6, 2018
fcab5c6
tests(healthchecks) adapt regression tests for routes & services
hishamhm Jan 20, 2018
9822815
tests(*) add old API tests to spec-old-api/
hishamhm Jan 17, 2018
366f51d
chore(*) run old API tests in spec-old-api/
hishamhm Jan 17, 2018
2401130
chore(luacheck) add exceptions for spec-old-api/
hishamhm Jan 17, 2018
d867c1d
tests(spec-old-api) rename all references of `spec` to `spec-old-api`
hishamhm Jan 20, 2018
1cdb8f3
tests(spec-old-api) fix string matching due to hyphens in spec-old-api
hishamhm Jan 22, 2018
8d572b3
tests(spec-old-api) resync with 0.12.1 master
hishamhm Jan 22, 2018
d297862
feat(plugins) support for api_id alongside route_id/service_id
thibaultcha Jan 19, 2018
586961e
tests(spec-old-api) disable encode_args() tests whose behavior changed
hishamhm Jan 22, 2018
cf2198e
feat(proxy) enable plugin runloop to work with apis for backward comp…
bungle Jan 19, 2018
b5b3804
feat(core) re-introduce API-based router
kikito Jan 19, 2018
f50d654
feat(*) make plugins backwards-compatible with APIs
bungle Jan 22, 2018
7fc5a90
fix(init) ensure DAO init errors are correctly reported
thibaultcha Jan 29, 2018
1028a45
fix(router) fix debug info to set correct debug entries in router
bungle Feb 2, 2018
debfadd
fix(admin) fix arguments parser and add tests
bungle Jan 5, 2018
317d0cf
feat(db) add select/update/delete by unique field
thibaultcha Feb 6, 2018
fc78dc7
fix(db) postgres update_by_field now allows to use different key in s…
bungle Feb 6, 2018
4eaca14
feat(router) use routes.regex_priority field for sorting routes
kikito Feb 7, 2018
ca03fa8
tests(reports) check reports of plugins added to APIs, Routes and Ser…
hishamhm Feb 6, 2018
1f862cc
feat(db) add select/update/delete by unique field in Cassandra strategy
thibaultcha Feb 9, 2018
6f41dbb
tests(old-spec) remove unnecessary tests and use new listener syntax +
thibaultcha Feb 9, 2018
399b2bf
feat(api) allow services to be accessible by both uuid and name
bungle Feb 6, 2018
90bde17
chore(db) remove 'fake' strategy
thibaultcha Feb 14, 2018
1fbfda2
chore(db) remove unused DAO/strategies overrides
thibaultcha Feb 14, 2018
8894e9d
feat(api) add /services/{service}/plugins AND /routes/{route}/plugins
bungle Feb 22, 2018
11ccaa3
chore(ci) enable C* 2.2 and OpenResty 1.13.6.1 testing
thibaultcha Feb 23, 2018
b324f20
feat(db) compat. with C* 2.x for reset() and truncate()
thibaultcha Feb 23, 2018
e828b6d
fix(dao) add index on Targets for C* < 3.6 support
thibaultcha Feb 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ elif [ "$TEST_SUITE" == "integration" ]; then
make test-integration
elif [ "$TEST_SUITE" == "plugins" ]; then
make test-plugins
elif [ "$TEST_SUITE" == "old-unit" ]; then
make old-test
elif [ "$TEST_SUITE" == "old-integration" ]; then
make old-test-integration
elif [ "$TEST_SUITE" == "old-plugins" ]; then
make old-test-plugins
fi
5 changes: 5 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ignore = {

exclude_files = {
"spec/fixtures/invalid-module.lua",
"spec-old-api/fixtures/invalid-module.lua",
}


Expand All @@ -38,3 +39,7 @@ files["kong/plugins/ldap-auth/*.lua"] = {
files["spec/**/*.lua"] = {
std = "ngx_lua+busted",
}

files["spec-old-api/**/*.lua"] = {
std = "ngx_lua+busted",
}
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
global:
- LUAROCKS=2.4.3
- OPENSSL=1.0.2n
- CASSANDRA=2.2.8
- CASSANDRA=3.9
- OPENRESTY_BASE=1.11.2.5
- OPENRESTY_LATEST=1.13.6.1
- OPENRESTY=$OPENRESTY_BASE
Expand All @@ -30,16 +30,21 @@ env:
matrix:
- TEST_SUITE=lint
- TEST_SUITE=unit
- TEST_SUITE=integration
OPENRESTY=$OPENRESTY_BASE
- TEST_SUITE=plugins
OPENRESTY=$OPENRESTY_BASE
- TEST_SUITE=integration
OPENRESTY=$OPENRESTY_LATEST
CASSANDRA=3.9
- TEST_SUITE=plugins
OPENRESTY=$OPENRESTY_LATEST
CASSANDRA=3.9
- TEST_SUITE=integration
OPENRESTY=$OPENRESTY_BASE
CASSANDRA=2.2
- TEST_SUITE=plugins
OPENRESTY=$OPENRESTY_BASE
CASSANDRA=2.2
- TEST_SUITE=old-unit
- TEST_SUITE=old-integration
OPENRESTY=$OPENRESTY_BASE
- TEST_SUITE=old-plugins
OPENRESTY=$OPENRESTY_BASE

before_install:
- source .ci/setup_env.sh
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@ test-plugins:

test-all:
@$(TEST_CMD) spec/

old-test:
@$(TEST_CMD) spec-old-api/01-unit

old-test-integration:
@$(TEST_CMD) spec-old-api/02-integration

old-test-plugins:
@$(TEST_CMD) spec-old-api/03-plugins

old-test-all:
@$(TEST_CMD) spec-old-api/
23 changes: 23 additions & 0 deletions kong-0.12.1-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ build = {

["kong.api"] = "kong/api/init.lua",
["kong.api.api_helpers"] = "kong/api/api_helpers.lua",
["kong.api.arguments"] = "kong/api/arguments.lua",
["kong.api.crud_helpers"] = "kong/api/crud_helpers.lua",
["kong.api.endpoints"] = "kong/api/endpoints.lua",
["kong.api.routes.kong"] = "kong/api/routes/kong.lua",
["kong.api.routes.apis"] = "kong/api/routes/apis.lua",
["kong.api.routes.consumers"] = "kong/api/routes/consumers.lua",
["kong.api.routes.plugins"] = "kong/api/routes/plugins.lua",
["kong.api.routes.routes"] = "kong/api/routes/routes.lua",
["kong.api.routes.services"] = "kong/api/routes/services.lua",
["kong.api.routes.cache"] = "kong/api/routes/cache.lua",
["kong.api.routes.upstreams"] = "kong/api/routes/upstreams.lua",
["kong.api.routes.certificates"] = "kong/api/routes/certificates.lua",
Expand All @@ -96,6 +100,7 @@ build = {
["kong.core.handler"] = "kong/core/handler.lua",
["kong.core.certificate"] = "kong/core/certificate.lua",
["kong.core.router"] = "kong/core/router.lua",
["kong.core.api_router"] = "kong/core/api_router.lua",
["kong.core.plugins_iterator"] = "kong/core/plugins_iterator.lua",
["kong.core.reports"] = "kong/core/reports.lua",
["kong.core.error_handlers"] = "kong/core/error_handlers.lua",
Expand All @@ -121,6 +126,24 @@ build = {
["kong.dao.migrations.cassandra"] = "kong/dao/migrations/cassandra.lua",
["kong.dao.migrations.postgres"] = "kong/dao/migrations/postgres.lua",

["kong.db"] = "kong/db/init.lua",
["kong.db.errors"] = "kong/db/errors.lua",
["kong.db.dao"] = "kong/db/dao/init.lua",
["kong.db.schema"] = "kong/db/schema/init.lua",
["kong.db.schema.entities.routes"] = "kong/db/schema/entities/routes.lua",
["kong.db.schema.entities.services"] = "kong/db/schema/entities/services.lua",
["kong.db.schema.entity"] = "kong/db/schema/entity.lua",
["kong.db.schema.metaschema"] = "kong/db/schema/metaschema.lua",
["kong.db.schema.typedefs"] = "kong/db/schema/typedefs.lua",
["kong.db.strategies"] = "kong/db/strategies/init.lua",
["kong.db.strategies.connector"] = "kong/db/strategies/connector.lua",
["kong.db.strategies.cassandra"] = "kong/db/strategies/cassandra/init.lua",
["kong.db.strategies.cassandra.connector"] = "kong/db/strategies/cassandra/connector.lua",
["kong.db.strategies.cassandra.routes"] = "kong/db/strategies/cassandra/routes.lua",
["kong.db.strategies.cassandra.services"] = "kong/db/strategies/cassandra/services.lua",
["kong.db.strategies.postgres"] = "kong/db/strategies/postgres/init.lua",
["kong.db.strategies.postgres.connector"] = "kong/db/strategies/postgres/connector.lua",

["kong.plugins.base_plugin"] = "kong/plugins/base_plugin.lua",

["kong.plugins.basic-auth.migrations.cassandra"] = "kong/plugins/basic-auth/migrations/cassandra.lua",
Expand Down
28 changes: 25 additions & 3 deletions kong/api/api_helpers.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
local pl_string = require "pl.stringx"
local utils = require "kong.tools.utils"
local url = require "socket.url"

local type = type
local pairs = pairs
local remove = table.remove
local tonumber = tonumber

local _M = {}

Expand Down Expand Up @@ -49,9 +51,15 @@ function _M.normalize_nested_params(obj)
end

-- normalize sub-keys with dot notation
local keys = pl_string.split(k, ".")
if #keys > 1 then -- we have a key containing a dot
attach_dotted_key(keys, new_obj, parse_value(v))
if type(k) == "string" then
local keys = pl_string.split(k, ".")
if #keys > 1 then -- we have a key containing a dot
attach_dotted_key(keys, new_obj, parse_value(v))

else
new_obj[k] = parse_value(v) -- nothing special with that key, simply attaching the value
end

else
new_obj[k] = parse_value(v) -- nothing special with that key, simply attaching the value
end
Expand All @@ -60,4 +68,18 @@ function _M.normalize_nested_params(obj)
return new_obj
end


function _M.resolve_url_params(self)
local sugar_url = self.args.post.url
if sugar_url then
local parsed_url = url.parse(sugar_url)
self.args.post.protocol = parsed_url.scheme
self.args.post.host = parsed_url.host
self.args.post.port = tonumber(parsed_url.port) or parsed_url.port
self.args.post.path = parsed_url.path
self.args.post.url = nil
end
end


return _M
Loading