-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Valentin Pichard <[email protected]>
- Loading branch information
1 parent
3515d5b
commit 4aaae74
Showing
16 changed files
with
327 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
cat <<EOF | ||
Hello world script | ||
{"dumb_string":"Hello $1!","random_object":{"foo":"bar"}} | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: exec-script | ||
description: Executing a shell script | ||
title_format: "[test] a simple task for script-plugin" | ||
|
||
inputs: | ||
- name: argv | ||
description: ARGV script input | ||
|
||
steps: | ||
stepOne: | ||
description: first step | ||
action: | ||
type: script | ||
configuration: | ||
# ____________________ | ||
# / \ | ||
# | This is only for | | ||
# | testing purpose | | ||
# \____________________/ | ||
# ! ! | ||
# ! ! | ||
# L_ ! | ||
# / _)! | ||
# / /__L | ||
# _____/ (____) | ||
# (____) | ||
# _____ (____) | ||
# \_(____) | ||
# ! ! | ||
# ! ! | ||
# \__/ | ||
# This file param is valid only in a testing context | ||
# In production, `file` will be prefixed by the utask.FScriptsFolder variable ("./scripts" by default) | ||
# You can specify your file's path relative to that location | ||
file: "./scripts_tests/hello-world.sh" | ||
argv: | ||
- "{{.input.argv}}" | ||
timeout_seconds: "25" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# `script` plugin | ||
|
||
This plugin execute a script. | ||
|
||
*Warn: This plugin will keep running until the execution is done* | ||
|
||
*Runtime(s) must be accessible on the host you deploy µTask if you want to execute interpreted scripts: [verify shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) and available packages* | ||
|
||
Files must be located under scripts folder, you should set exec permissions (+x). Otherwise the script plugin will try to set the exec permissions. | ||
|
||
## Configuration | ||
|
||
|Fields|Description | ||
|---|--- | ||
| `file` | file name under scripts folder | ||
| `argv` | a collection of script argv | ||
| `timeout` | timeout of the script execution | ||
| `stdin` | inject stdin in your script | ||
| `last_line_not_json` | skip or not unmarshaling of last JSON line | ||
| `allow_exit_non_zero` | allow or not non zero exit status code | ||
|
||
## Example | ||
|
||
An action of type `script` requires the following kind of configuration: | ||
|
||
```yaml | ||
action: | ||
type: script | ||
configuration: | ||
# mandatory, string | ||
# file field must be related to you scripts path (./scripts) | ||
# and could modified /w `scripts-path` flag when you run binary | ||
file: hello-world.sh | ||
# optional, a collection of string | ||
argv: | ||
- world | ||
# optional, string as Duration | ||
# Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". | ||
# default is 2m | ||
timeout: "25s" | ||
# optional, boolean | ||
# default is false, can't be templated | ||
last_line_not_json: false | ||
# optional, boolean | ||
# default is false, can't be templated | ||
allow_exit_non_zero: false | ||
``` | ||
## Note | ||
The plugin returns two objects, the `Payload` who is the last returned line of your script as json: | ||
|
||
```json | ||
{"dumb_string":"Hello world!","random_object":{"foo":"bar"}} | ||
``` | ||
|
||
*Your JSON must be printed on last line* | ||
|
||
The `Metadata` to fetch informations about plugin execution: | ||
|
||
```js | ||
{ | ||
"exit_code":"0", | ||
"process_state":"exit status 0", | ||
// Output combine Stdout and Stderr streams without any distinction | ||
"output":"Hello world script\n{\"dumb_string\":\"Hello world!\",\"random_object\":{\"foo\":\"bar\"}}\n", | ||
"execution_time":"846.889µs", | ||
"error":"" | ||
} | ||
``` |
Oops, something went wrong.