-
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
feat: validate apisix.yaml
for config_provider yaml
#10630
Conversation
This prototype tries to show a way to validate the `apisix.yaml` by starting openresty and only running the validation code. As part of the validation we initialize the configuration and then check if no errors where logs. If any errors are logged then the `apisix test` command fails. Special thanks to https://github.com/openresty/resty-cli/!
apisix.yaml
for config_provider yamlapisix.yaml
for config_provider yaml
Nice work! We really appreciate this! we will check it later |
|
||
local valid = true | ||
for module_name, cfg_func in pairs(modules) do | ||
apisix_core.log.no_error_logs = true |
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 assume this was added by mistake (duplicate exists in L#919)
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.
This was actually done on purpose.
As apisix_core.log.error
can set the variable to false
.
By setting it to true
here we can have a valid check per module
.
@@ -153,7 +153,7 @@ local function get_lua_path(conf) | |||
end | |||
|
|||
|
|||
local function init(env) | |||
local function init_sysconf(env) |
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.
can you explain what have you done here?
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 extracted this method from local function init(env)
so it can also be used by local function test_standalone(env)
.
As the information from init_sysconf
is used to render apisix.cli.ngx_cli_tpl
.
hi @boekkooi-lengoo the code is a bit complicated, could you describe your thought in detail? |
I agree the code is a bit complicated. Now it turns out that to use "apisix.core.schema" I needed to require some of the After some reseacth it seems that it would be very hard to simply validate schemas as it seems that each module/part is doing validation differently. Now for the validation we assume that any call to the logger with level Personally this entire thing feels a bit hacky but due to my lack of understanding of the internal design choices and lua knowledge I wanted to show this so we could analyses and discuss better options. I hope this clarifies my thoughts a bit. |
ok, we will figure out your design, please be patient |
We have the command |
@monkeyDluffy6017 I don't really understand your question as this code already adds the validation to apisix test in https://github.com/apache/apisix/pull/10630/files#diff-3936316fb5318f20b79ffe05648cf3d6b8c61e6987b51b52e2571c8a8e73a68bR795 can you maybe clarify what you mean? |
@boekkooi-lengoo what i mean is that the |
@monkeyDluffy6017 they could be confusing as they confused me already because I assumed wrongly that |
OK, LGTM, please go ahead |
Hey y'all, Thanks again for the reviews, input and support I very much appreciate it! |
Description
This prototype tries to show a way to validate the
apisix.yaml
by starting openresty and only running the validation code.As part of the validation we initialize the configuration and then check if no errors where logs. If any errors are logged then the
apisix test
command fails.Special thanks to https://github.com/openresty/resty-cli/!
Fixes #10583
Checklist