You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/01/26 01:59:27 UTC

[GitHub] [apisix] spacewander opened a new pull request #3417: feat: allow customizing lua_package_path & lua_package_cpath

spacewander opened a new pull request #3417:
URL: https://github.com/apache/apisix/pull/3417


   Signed-off-by: spacewander <sp...@gmail.com>
   
   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   
   ### Pre-submission checklist:
   
   * [x] Did you explain what problem does this PR solve? Or what new features have been added?
   * [x] Have you added corresponding test cases?
   * [x] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #3417: feat: allow customizing lua_package_path & lua_package_cpath

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #3417:
URL: https://github.com/apache/apisix/pull/3417#discussion_r564975536



##########
File path: apisix/cli/ops.lua
##########
@@ -121,6 +122,19 @@ local function version()
 end
 
 
+local function get_lua_path(conf)
+    if conf then
+        local path = conf
+        if path:byte(-1) ~= str_byte(';') then
+            path = path .. ';'

Review comment:
       updated.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tokers commented on a change in pull request #3417: feat: allow customizing lua_package_path & lua_package_cpath

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #3417:
URL: https://github.com/apache/apisix/pull/3417#discussion_r564421467



##########
File path: apisix/cli/ops.lua
##########
@@ -121,6 +122,19 @@ local function version()
 end
 
 
+local function get_lua_path(conf)
+    if conf then
+        local path = conf
+        if path:byte(-1) ~= str_byte(';') then
+            path = path .. ';'

Review comment:
       if conf is `""`, it'll return `";"`, is this OK for the `lua_package_path` directive?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tokers commented on a change in pull request #3417: feat: allow customizing lua_package_path & lua_package_cpath

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #3417:
URL: https://github.com/apache/apisix/pull/3417#discussion_r564420468



##########
File path: doc/plugin-develop.md
##########
@@ -29,10 +30,39 @@
 - [**register public API**](#register-public-api)
 - [**register control API**](#register-control-api)
 
+## where to put your plugin

Review comment:
       plugin => plugins.

##########
File path: apisix/cli/ops.lua
##########
@@ -121,6 +122,19 @@ local function version()
 end
 
 
+local function get_lua_path(conf)
+    if conf then
+        local path = conf
+        if path:byte(-1) ~= str_byte(';') then
+            path = path .. ';'

Review comment:
       if conf is `"="`, it'll return `";"`, is this OK for the `lua_package_path` directive?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander merged pull request #3417: feat: allow customizing lua_package_path & lua_package_cpath

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #3417:
URL: https://github.com/apache/apisix/pull/3417


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #3417: feat: allow customizing lua_package_path & lua_package_cpath

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #3417:
URL: https://github.com/apache/apisix/pull/3417#discussion_r564279827



##########
File path: .travis/apisix_cli_test/test_main.sh
##########
@@ -1013,3 +1013,27 @@ echo "passed: show password error successfully"
 etcdctl --endpoints=127.0.0.1:2379 --user=root:apache-api6 auth disable
 etcdctl --endpoints=127.0.0.1:2379 role delete root
 etcdctl --endpoints=127.0.0.1:2379 user delete root
+
+# support 3rd-party plugin
+echo '
+apisix:
+    extra_lua_path: "\$prefix/example/?.lua"
+    extra_lua_cpath: "\$prefix/example/?.lua"
+plugins:
+    - 3rd-party
+stream_plugins:
+    - 3rd-party
+' > conf/config.yaml
+
+rm logs/error.log
+make init
+make run
+
+sleep 0.5
+make stop
+
+if grep "failed to load plugin [3rd-party]" logs/error.log > /dev/null; then
+    echo "failed: 3rd party plugin can not be loaded"

Review comment:
       Updated.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Firstsawyou commented on a change in pull request #3417: feat: allow customizing lua_package_path & lua_package_cpath

Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on a change in pull request #3417:
URL: https://github.com/apache/apisix/pull/3417#discussion_r564240394



##########
File path: .travis/apisix_cli_test/test_main.sh
##########
@@ -1013,3 +1013,27 @@ echo "passed: show password error successfully"
 etcdctl --endpoints=127.0.0.1:2379 --user=root:apache-api6 auth disable
 etcdctl --endpoints=127.0.0.1:2379 role delete root
 etcdctl --endpoints=127.0.0.1:2379 user delete root
+
+# support 3rd-party plugin
+echo '
+apisix:
+    extra_lua_path: "\$prefix/example/?.lua"
+    extra_lua_cpath: "\$prefix/example/?.lua"
+plugins:
+    - 3rd-party
+stream_plugins:
+    - 3rd-party
+' > conf/config.yaml
+
+rm logs/error.log
+make init
+make run
+
+sleep 0.5
+make stop
+
+if grep "failed to load plugin [3rd-party]" logs/error.log > /dev/null; then
+    echo "failed: 3rd party plugin can not be loaded"

Review comment:
       I think it’s better to use `3rd-party` to keep the plugin name consistent,

##########
File path: .travis/apisix_cli_test/test_main.sh
##########
@@ -1013,3 +1013,27 @@ echo "passed: show password error successfully"
 etcdctl --endpoints=127.0.0.1:2379 --user=root:apache-api6 auth disable
 etcdctl --endpoints=127.0.0.1:2379 role delete root
 etcdctl --endpoints=127.0.0.1:2379 user delete root
+
+# support 3rd-party plugin
+echo '
+apisix:
+    extra_lua_path: "\$prefix/example/?.lua"
+    extra_lua_cpath: "\$prefix/example/?.lua"
+plugins:
+    - 3rd-party
+stream_plugins:
+    - 3rd-party
+' > conf/config.yaml
+
+rm logs/error.log
+make init
+make run
+
+sleep 0.5
+make stop
+
+if grep "failed to load plugin [3rd-party]" logs/error.log > /dev/null; then
+    echo "failed: 3rd party plugin can not be loaded"
+    exit 1
+fi
+echo "passed: 3rd party plugin can be loaded"

Review comment:
       ditto.
   
   
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org