Skip to content

Commit 803410e

Browse files
w3st3ryrbeuque74
authored andcommitted
Fix relative file path bug + rename file field (#68)
Signed-off-by: Valentin Pichard <[email protected]>
1 parent 88ada50 commit 803410e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

engine/templates_tests/execScript.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ steps:
3232
# This file param is valid only in a testing context
3333
# In production, `file` will be prefixed by the utask.FScriptsFolder variable ("./scripts" by default)
3434
# You can specify your file's path relative to that location
35-
file: "./scripts_tests/hello-world.sh"
35+
file_path: "./scripts_tests/hello-world.sh"
3636
argv:
3737
- "{{.input.argv}}"
3838
timeout_seconds: "25"

pkg/plugins/builtin/script/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Files must be located under scripts folder, you should set exec permissions (+x)
1212

1313
|Fields|Description
1414
|---|---
15-
| `file` | file name under scripts folder
15+
| `file_path` | file name under scripts folder
1616
| `argv` | a collection of script argv
1717
| `timeout` | timeout of the script execution
1818
| `stdin` | inject stdin in your script
@@ -28,9 +28,9 @@ action:
2828
type: script
2929
configuration:
3030
# mandatory, string
31-
# file field must be related to you scripts path (./scripts)
31+
# file_path field must be related to you scripts path (./scripts)
3232
# and could modified /w `scripts-path` flag when you run binary
33-
file: hello-world.sh
33+
file_path: hello-world.sh
3434
# optional, a collection of string
3535
argv:
3636
- world

pkg/plugins/builtin/script/script.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
// the script plugin execute scripts
2121
var (
22-
Plugin = taskplugin.New("script", "0.1", exec,
22+
Plugin = taskplugin.New("script", "0.2", exec,
2323
taskplugin.WithConfig(validConfig, Config{}),
2424
)
2525
)
@@ -35,7 +35,7 @@ type Metadata struct {
3535

3636
// Config is the configuration needed to execute a script
3737
type Config struct {
38-
File string `json:"file"`
38+
File string `json:"file_path"`
3939
Argv []string `json:"argv,omitempty"`
4040
Timeout string `json:"timeout,omitempty"`
4141
Stdin string `json:"stdin,omitempty"`
@@ -88,7 +88,7 @@ func exec(stepName string, config interface{}, ctx interface{}) (interface{}, in
8888
ctxe, cancel := context.WithTimeout(context.Background(), timeout)
8989
defer cancel()
9090

91-
cmd := gexec.CommandContext(ctxe, filepath.Join(utask.FScriptsFolder, cfg.File), cfg.Argv...)
91+
cmd := gexec.CommandContext(ctxe, fmt.Sprintf("./%s", cfg.File), cfg.Argv...)
9292
cmd.Dir = utask.FScriptsFolder
9393
cmd.Stdin = strings.NewReader(cfg.Stdin)
9494

0 commit comments

Comments
 (0)