feat: lua script commands triggers - #447
Abhishek84313 wants to merge 2 commits into
Conversation
|
This PR doesn't contain any Lua. The branch is Zero files under Separately, this diff is byte-identical to #446 (both 1950 lines), and #438 is the R subset of both. So #438, #446 and #447 are three PRs carrying overlapping copies of the same commits rather than one module each. Merging any one of them will conflict the other two. Could you rebase each onto current main with only its own module: #438 R, #446 Perl, and this one Lua? I'll review them properly once they're separated. Nothing here reflects on the code itself, I just can't review Lua triggers that aren't in the diff. |
What changes are being made and why?
Adds
ScriptTriggerandCommandsTriggertoplugin-script-lua, which was one of the submodules still missing them.Part of #313, closes #428.
Both triggers live in
io.kestra.plugin.scripts.lua— the same package as theScriptandCommandstasks, with no nested subpackage — matching the existing implementations inplugin-script-go,plugin-script-node,plugin-script-python,plugin-script-rubyandplugin-script-shell.ScriptTriggerpolls by running an inline Lua script through theScripttask and emits an execution when the condition matches.CommandsTriggerdoes the same for a list of commands through theCommandstask.Each trigger exposes:
containerImagenickblah/luascript/commandsexitConditionintervalPT60SedgetrueexitConditionaccepts eitherexit N, which compares against the process exit code, or any other string, which is treated as a regex (falling back to a substring match if the regex is invalid) against vars emitted via the::{"outputs":{...}}::convention.The trigger output carries
timestamp,condition,exitCodeandvars; execution id, namespace and flow id come from the standardTriggerService.generateExecutioncontext. A failed evaluation is logged and returns empty rather than propagating, so a broken script cannot block the scheduler.plugin-script-lua/build.gradlegains theschedulerandworkertest dependencies that the trigger tests require, matching the other submodules.Note on the issue's proposed properties
The issue sketches
commandPatternandargumentsPatternalongsideexitCondition. This PR implements onlyexitCondition, consistent with all five existing reference implementations. These triggers run the script themselves rather than observing externally-launched executions, so there is no command stream to pattern-match against — the command is whatever the trigger was configured with. Adding the two pattern properties to Lua alone would diverge from every other submodule; if they are wanted, they belong in a separate change applied across all of them.How the changes have been QAed?
Unit and condition-matching tests were added for both triggers (
ScriptTriggerTest,CommandsTriggerTest,ScriptTriggerConditionTest,CommandsTriggerConditionTest), covering exit-code conditions, regex and substring matching against emitted vars, empty/null conditions, and edge-mode transition behaviour.The 36 tests that do not require Docker pass locally, and
compileJava,compileTestJavaandbuildall succeed. The four Docker-backed cases inCommandsTriggerTestcould not be run on the development machine, which has no Docker available — they need a CI run to confirm. They uselua -e "os.exit(1)"/os.exit(0)againstnickblah/lua:latest, consistent with the existingCommandsTestand theall_lua.yamlsanity check that already invokeluain that image.Trigger on a failing script:
Trigger on commands matching emitted output:
Contributor Checklist ✅