Taha Sadiki
06/06/2023, 11:30 AMname: test_action
...
hooks:
- id: test_hook
type: lua
properties:
script_path: _scripts/test_script.lua
and I placed my Lua script under the _script/
prefix in my repo, and also added another module mymodule.lua
under that same prefix:
_scripts/
test_script.lua
mymodule.lua
and I want to import and use mymodule
in test_script.lua
and I tried a few things but I keep getting “module not found” errors. I’m not very familiar with Lua so I’m not sure if this is a Lua programming thing or if it’s related to where the scripts are stored and organized in Lakefs server.
Any help with this is greatly appreciatedItai Admi
06/06/2023, 11:43 AMOz Katz
Taha Sadiki
06/06/2023, 1:03 PMname: test_action
...
hooks:
- id: test_hook
type: lua
properties:
script_path: _scripts/test_script.lua
script_dependencies:
- _script/mymodule.lua
and then only allow importing from those declared dependencies. I’m wondering if that would reduce the security risk and simplify managing permissions?Oz Katz
sys.path
could be adapted to this.properties.args.run
flag that accepts a name of a function to run.
This has the benefit of only having to maintain one copy of shared code, but is probably not as easy to maintain as proper modules.
Here's an example of what that might look like:
name: Execute Things
description: do things
on:
post-commit:
hooks:
- id: do_stuff
type: lua
properties:
script_path: scripts/run_stuff.lua
args:
run: this_function
With the script simply executing the passed function:
function this_function()
print("doing this!!")
end
function that_function()
print("doing that!!")
end
actions = {
["this_function"] = this_function,
["that_function"] = that_function,
}
actions[args.run]()
Would that be helpful as an interim solution?Taha Sadiki
06/06/2023, 5:33 PM