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

Feat/syslog #696

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8954a1e
Adding a function to count the entities in a table
subnetmarco Oct 13, 2015
806ae78
Disabling access log for status endpoint
subnetmarco Oct 14, 2015
787b99e
Merge pull request #623 from Mashape/fix/status-logs
subnetmarco Oct 14, 2015
d26c761
Customizable DNS settings
subnetmarco Oct 15, 2015
3114ef7
Merge pull request #625 from Mashape/feat/custom-dns
subnetmarco Oct 15, 2015
731e203
fix(alf_serializer) always ensure mimeType is a string
thibaultcha Oct 15, 2015
956f94d
perf(alf_serializer) globals optimizations
thibaultcha Oct 15, 2015
eef305a
Merge pull request #626 from Mashape/fix/alf-serializer
thibaultcha Oct 15, 2015
c0ab86d
OAuth 2.0 tests to check for upstream headers
subnetmarco Oct 15, 2015
a0fc23f
Merge pull request #627 from Mashape/tests/oauth2
subnetmarco Oct 15, 2015
aa54b58
Updating dependencies
subnetmarco Oct 15, 2015
709f4b9
Merge pull request #628 from Mashape/enhancement/updating-dependencies
subnetmarco Oct 15, 2015
b912125
Merge pull request #632 from Mashape/dao/count
subnetmarco Oct 15, 2015
57b9e30
feat(cli) config validation and defaults utility
thibaultcha Oct 7, 2015
d26e179
feat(cli) use new config and dao loaders
thibaultcha Oct 7, 2015
92a37c8
Adding "total" field in API responses
subnetmarco Oct 15, 2015
21d77a5
Adding database stats into status endpoint
subnetmarco Oct 16, 2015
9f2e83a
Merge pull request #635 from Mashape/chore/api-totals
subnetmarco Oct 16, 2015
94747d8
Updating changelog for 0.6.x
subnetmarco Oct 16, 2015
15addbf
Refactoring the count function in DAO and API
subnetmarco Oct 16, 2015
d0edd94
Merge pull request #636 from Mashape/refactor/count
thibaultcha Oct 16, 2015
370f124
feat(config) commented configuration file
thibaultcha Oct 8, 2015
121a949
feat(config) add options for keyspace replication strategy
thibaultcha Sep 30, 2015
ccac50b
refactor(config) remove unnecessary dao config nesting
thibaultcha Oct 5, 2015
15e6205
feat(config) implement `enum` check for properties
thibaultcha Oct 16, 2015
303e235
feat(config) update `kong config` to new config file format
thibaultcha Oct 16, 2015
12d8171
Merge pull request #633 from Mashape/feat/commented-config
thibaultcha Oct 16, 2015
b97eef2
fix(readme): update community resources
Oct 16, 2015
fcfdc4d
Merge pull request #637 from Mashape/readme-patch
Oct 16, 2015
daa8632
Merge branch 'sinzone-patch-1' into next
thibaultcha Oct 19, 2015
99d584d
docs(readme)
sonicaghi Oct 19, 2015
50382d4
fix(config/rockspec) add missing files and remove dnsmasq_port property
thibaultcha Oct 20, 2015
f2f84fd
Merge pull request #645 from Mashape/fix/config
thibaultcha Oct 20, 2015
34fd7d8
Merge branch 'sinzone-patch-1' into next
thibaultcha Oct 20, 2015
00e5e2b
Merge branch 'master' into next
thibaultcha Oct 21, 2015
fb22f93
chore(ci) bump Cassandra version
thibaultcha Oct 21, 2015
77fd7e1
Merge pull request #649 from Mashape/chore/bump-cassandra
thibaultcha Oct 21, 2015
5163571
Merge remote-tracking branch 'mybuilder/fix-oauth2-https-check' into …
thibaultcha Oct 21, 2015
635daf0
Merge branch 'hotfix/hmac-date' into next
thibaultcha Oct 21, 2015
2bf4def
Merge branch 'release/0.5.2' into next
thibaultcha Oct 22, 2015
7595850
Merge branch 'hotfix/path-search' into next
thibaultcha Oct 22, 2015
6df7bbd
docs(ldoc) better documentation for public Lua API
thibaultcha Oct 27, 2015
e029020
Merge pull request #657 from Mashape/docs/comments
thibaultcha Oct 27, 2015
7d5420d
fix: remove erroneous inspect statement
thibaultcha Oct 27, 2015
5b6fe1f
syslog and loggly plugins
Nov 5, 2015
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
Prev Previous commit
Next Next commit
feat(config) implement enum check for properties
  • Loading branch information
thibaultcha committed Oct 16, 2015
commit 15e62059d08384da9544452c50a76888126954e2
4 changes: 2 additions & 2 deletions kong/tools/config_defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ return {
["proxy_port"] = {type = "number", default = 8000},
["proxy_ssl_port"] = {type = "number", default = 8443},
["admin_api_port"] = {type = "number", default = 8001},
["dns_resolver"] = {type = "string", default = "dnsmasq"},
["dns_resolver"] = {type = "string", default = "dnsmasq", enum = {"server", "dnsmasq"}},
["dns_resolvers_available"] = {
type = "table",
content = {
Expand Down Expand Up @@ -38,7 +38,7 @@ return {
["timeout"] = {type = "number", default = 1000},
["keyspace"] = {type = "string", default = "kong"},
["keepalive"] = {type = "number", default = 60000},
["replication_strategy"] = {type = "string", default = "SimpleStrategy"},
["replication_strategy"] = {type = "string", default = "SimpleStrategy", enum = {"SimpleStrategy", "NetworkTopologyStrategy"}},
["replication_factor"] = {type = "number", default = 1},
["data_centers"] = {type = "table", default = {}},
["ssl"] = {type = "boolean", default = false},
Expand Down
33 changes: 25 additions & 8 deletions kong/tools/config_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ local function get_type(value, val_type)
end
end

local checks = {
type = function(value, key_infos, value_type)
if value_type ~= key_infos.type then
return "must be a "..key_infos.type
end
end,
minimum = function(value, key_infos, value_type)
if value_type == "number" and key_infos.min ~= nil and value < key_infos.min then
return "must be greater than "..key_infos.min
end
end,
enum = function(value, key_infos, value_type)
if key_infos.enum ~= nil and not utils.table_contains(key_infos.enum, value) then
return string.format("must be one of: '%s'", table.concat(key_infos.enum, ", "))
end
end
}

local function validate_config_schema(config, config_schema)
if not config_schema then config_schema = config_defaults end
local errors, property
Expand All @@ -30,7 +48,6 @@ local function validate_config_schema(config, config_schema)

local ok, s_errors = validate_config_schema(property, key_infos.content)
if not ok then
--errors = utils.add_error(errors, config_key, s_errors)
for s_k, s_v in pairs(s_errors) do
errors = utils.add_error(errors, config_key.."."..s_k, s_v)
end
Expand All @@ -40,13 +57,13 @@ local function validate_config_schema(config, config_schema)
-- Nullable checking
if property ~= nil and not key_infos.nullable then
local property_type = get_type(property, key_infos.type)
-- Type checking
if property_type ~= key_infos.type then
errors = utils.add_error(errors, config_key, "must be a "..key_infos.type)
end
-- Min checking
if property_type == "number" and key_infos.min ~= nil and property < key_infos.min then
errors = utils.add_error(errors, config_key, "must be greater than "..key_infos.min)
local err
-- Individual checks
for _, check_fun in pairs(checks) do
err = check_fun(property, key_infos, property_type)
if err then
errors = utils.add_error(errors, config_key, err)
end
end
end

Expand Down
11 changes: 11 additions & 0 deletions spec/unit/tools/config_loader_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ describe("Configuration validation", function()
assert.False(ok)
assert.equal("must be greater than 32", errors.memory_cache_size)
end)
it("should check that the value is contained in `enum`", function()
local ok, errors = config.validate({
databases_available = {
cassandra = {
replication_strategy = "foo"
}
}
})
assert.False(ok)
assert.equal("must be one of: 'SimpleStrategy, NetworkTopologyStrategy'", errors["databases_available.cassandra.replication_strategy"])
end)
it("should validate the selected database property", function()
local ok, errors = config.validate({database = "foo"})
assert.False(ok)
Expand Down