boekkooi-lengoo commented on PR #10630:
URL: https://github.com/apache/apisix/pull/10630#issuecomment-1885141759

   Hey @monkeyDluffy6017 
   
   I agree the code is a bit complicated.
   So my original goal was to validate the `apisix.yaml` schema (using 
"apisix.core.schema") at a minimum and if possible to validate the values of 
the config file as well.
   
   Now it turns out that to use  "apisix.core.schema" I needed to require some 
of the `ngx` modules. 
   To do this I created a setup similar to 
https://github.com/openresty/resty-cli/ which allows the [execution of lua in 
nginx as a command line 
command](https://github.com/apache/apisix/pull/10630/files#diff-228a51571b53709ad043d1c6c14fc8e508c248a84f8014fe548b5d259cedd5ddR957-R958).
   This allow the ability to run code with all the requires modules.
   
   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. 
   So for the sake of the prototype I split each module/part to it's own 
[validation 
call](https://github.com/apache/apisix/pull/10630/files#diff-228a51571b53709ad043d1c6c14fc8e508c248a84f8014fe548b5d259cedd5ddR898-R902).
   
   Now for the validation we assume that any call to the [logger with level 
`error`](https://github.com/apache/apisix/pull/10630/files#diff-228a51571b53709ad043d1c6c14fc8e508c248a84f8014fe548b5d259cedd5ddR918-R923)
 means that the configuration is invalid.
   
   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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to