Open
Description
It would be nice1 to have an Execute
method to run commands in any of the active instances.
terraform-provider-iterative/task/task.go
Lines 37 to 47 in 57625b6
Loose ends
- How to deal with parallelism?
- Run the command on every instance and return a slice of results.
- Allow users to specify an index in the range
[0, parallelism[
and return an error if there aren't enough instances running to satisfy the requested index. - Allow users to list the running instances for a given task and select one of them to run the command on.
Pick a random instance every time.I had to include it. 😂
Draft proposal
-
Execute(instance uint16, input string, command ...string) (Result, error)
instance
represents the instance index in the range[0, parallelism[
; maybe we can use a string identifier instead.input
optionally, the standard input to feed the remote command with;""
will disable this function.command
is the slice of exec–like arguments; “no arguments” can default tosh
orbash
if appropriate.Result
is astruct
containing- Standard output
- Standard error
- Exit code
-
ExecuteTTY(instance uint16, streams Streams, command ...string) error
Same as above but with TTY and interactive streams, so it behaves like an ordinary SSH session. Seekubectl exec
for an example implementation.
Footnotes
-
Not necessary because Integrate task resource #237 eliminates the need of SSH by implementing Standardize on logs and storage for communication #126 ↩