Skip to content

Commit

Permalink
Fix relative file path bug + rename file field (#68)
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Pichard <[email protected]>
  • Loading branch information
w3st3ry authored and rbeuque74 committed Jan 15, 2020
1 parent 88ada50 commit 803410e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion engine/templates_tests/execScript.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ steps:
# 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"
file_path: "./scripts_tests/hello-world.sh"
argv:
- "{{.input.argv}}"
timeout_seconds: "25"
6 changes: 3 additions & 3 deletions pkg/plugins/builtin/script/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Files must be located under scripts folder, you should set exec permissions (+x)

|Fields|Description
|---|---
| `file` | file name under scripts folder
| `file_path` | file name under scripts folder
| `argv` | a collection of script argv
| `timeout` | timeout of the script execution
| `stdin` | inject stdin in your script
Expand All @@ -28,9 +28,9 @@ action:
type: script
configuration:
# mandatory, string
# file field must be related to you scripts path (./scripts)
# file_path field must be related to you scripts path (./scripts)
# and could modified /w `scripts-path` flag when you run binary
file: hello-world.sh
file_path: hello-world.sh
# optional, a collection of string
argv:
- world
Expand Down
6 changes: 3 additions & 3 deletions pkg/plugins/builtin/script/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

// the script plugin execute scripts
var (
Plugin = taskplugin.New("script", "0.1", exec,
Plugin = taskplugin.New("script", "0.2", exec,
taskplugin.WithConfig(validConfig, Config{}),
)
)
Expand All @@ -35,7 +35,7 @@ type Metadata struct {

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

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

Expand Down

0 comments on commit 803410e

Please sign in to comment.