Skip to content

Commit

Permalink
Merge pull request #39 from ethpandaops/skylenet/run_shell_args
Browse files Browse the repository at this point in the history
tasks/run_shell: add shellArgs
  • Loading branch information
skylenet authored Sep 13, 2024
2 parents 91da5cd + cf0891f commit 263f556
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 6 additions & 2 deletions pkg/coordinator/tasks/run_shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ The `run_shell` task executes a series of commands within a shell environment. T
- **`shell`**:\
Specifies the type of shell to use for running the commands. Common shells include `sh`, `bash`, `zsh`, etc. The default is `sh`.

- **`shellArgs`**:\
Additional arguments to pass to the shell. Example: `--login`.

- **`envVars`**:\
A dictionary specifying the environment variables to be used within the shell. Each key in this dictionary represents the name of an environment variable, and its corresponding value indicates the name of a variable from which the actual value should be read. \
For instance, if `envVars` is set as `{"PATH_VAR": "MY_PATH", "USER_VAR": "MY_USER"}`, the task will use the values of `MY_PATH` and `MY_USER` variables from the current task variable context as the values for `PATH_VAR` and `USER_VAR` within the shell.
Expand All @@ -27,7 +30,7 @@ echo "::set-var USER_VAR new value"
This feature allows the shell script to interact dynamically with the task context, modifying variables based on script execution.

Please note that this feature is still under development and the format of these triggers may change in future versions of the tool. It's important to stay updated with the latest documentation and release notes for any modifications to this functionality.


### Defaults

Expand All @@ -36,7 +39,8 @@ Default settings for the `run_shell` task:
```yaml
- name: run_shell
config:
shell: sh
shell: bash
shellArgs: []
envVars: {}
command: ""
```
10 changes: 6 additions & 4 deletions pkg/coordinator/tasks/run_shell/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ package runshell
import "errors"

type Config struct {
Shell string `yaml:"shell" json:"shell"`
EnvVars map[string]string `yaml:"envVars" json:"envVars"`
Command string `yaml:"command" json:"command"`
Shell string `yaml:"shell" json:"shell"`
ShellArgs []string `yaml:"shellArgs" json:"shellArgs"`
EnvVars map[string]string `yaml:"envVars" json:"envVars"`
Command string `yaml:"command" json:"command"`
}

func DefaultConfig() Config {
return Config{
Shell: "bash",
Shell: "bash",
ShellArgs: []string{},
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/coordinator/tasks/run_shell/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (t *Task) Execute(ctx context.Context) error {
cmdLogger.Info("running command")

//nolint:gosec // ignore
command := exec.CommandContext(ctx, t.config.Shell)
command := exec.CommandContext(ctx, t.config.Shell, t.config.ShellArgs...)

stdin, err := command.StdinPipe()
if err != nil {
Expand Down

0 comments on commit 263f556

Please sign in to comment.