-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: validation during merging node_listen configuration #4881
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,28 @@ local function tinyyaml_type(t) | |
end | ||
|
||
|
||
local function path_is_multi_type(path, type_val) | ||
if str_sub(path, 1, 14) == "nginx_config->" and | ||
(type_val == "number" or type_val == "string") then | ||
return true | ||
end | ||
|
||
if path == "apisix->node_listen" and type_val == "number" then | ||
return true | ||
end | ||
|
||
if path == "apisix->ssl->listen_port" and type_val == "number" then | ||
return true | ||
end | ||
|
||
if path == "apisix->ssl->listen" and type_val == "number" then | ||
return true | ||
end | ||
|
||
return false | ||
end | ||
|
||
|
||
local function merge_conf(base, new_tab, ppath) | ||
ppath = ppath or "" | ||
|
||
|
@@ -143,12 +165,11 @@ local function merge_conf(base, new_tab, ppath) | |
if base[key] == nil then | ||
base[key] = val | ||
elseif type(base[key]) ~= type_val then | ||
if (ppath == "nginx_config" or str_sub(ppath, 1, 14) == "nginx_config->") and | ||
(type_val == "number" or type_val == "string") | ||
then | ||
local path = ppath == "" and key or ppath .. "->" .. key | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use JSON schema to check it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @membphis The old code has been the schema like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, got it. thx |
||
|
||
if path_is_multi_type(path, type_val) then | ||
base[key] = val | ||
else | ||
local path = ppath == "" and key or ppath .. "->" .. key | ||
return nil, "failed to merge, path[" .. path .. "] expect: " .. | ||
type(base[key]) .. ", but got: " .. type_val | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what
apisix->ssl->listen
it is?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tzssangglass The config
apisix.ssl.listen
will be used in another PR (#4856). This will not affect the current code, do I remove it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think remove it is better and add it to the PRs that need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I have removed it, please retest. @tzssangglass