Add all 16 _by_lua_block and 9 _by_lua directives to crossplane along with tests.
Add Lua lexer to allow Crossplane to read Lua blocks
Add Lua built
Fix incorrect Lua testdata
How do we parse Lua:
In lexer:
Grab everything in the Lua block as a single token and drop the {}. Example:
content_by_lua_block {some code} will be content_by_lua_block "some code"; "some code" is an argument of directive
If a user puts the same argument name as the Lua block directives' name, we will treat it as a normal argument parse. Check if it starts with { which means token depth == 0.
If a user puts the same upstream name as the Lua block directives' name, we will treat it as a normal argument parse. Check if the token is a directive
Set_by_lua_block has a return value, so we need to additionally check for this directive. Get the return value token first and then obtain the rest of the block token.
If a user puts quotes around the Lua directives, we need to skip these quotes.
If there are braces inside the Lua block, we should retain them and not remove them as we did in # 1.
In parser (analyzer):
We want to use normal directives way to parse lua block, so
remove ngxConfBlock and change ngxConfNoArgs to ngxConfTake1, for set_by_lua_block change to ngxConfTake2. Just similar to server_name
In builder:
Add ExternalBuild to handle specific directives
Add { } back to the string
Checklist
Before creating a PR, run through this checklist and mark each as complete.
Proposed changes
Add all 16 _by_lua_block and 9 _by_lua directives to crossplane along with tests. Add Lua lexer to allow Crossplane to read Lua blocks Add Lua built Fix incorrect Lua testdata
How do we parse Lua: In lexer:
content_by_lua_block {some code}
will becontent_by_lua_block "some code";
"some code" is an argument of directiveIn parser (analyzer): We want to use normal directives way to parse lua block, so remove
ngxConfBlock
and changengxConfNoArgs
tongxConfTake1
, forset_by_lua_block
change tongxConfTake2
. Just similar toserver_name
In builder: Add
ExternalBuild
to handle specific directives Add{ }
back to the stringChecklist
Before creating a PR, run through this checklist and mark each as complete.
CONTRIBUTING
documentREADME.md
)