Skip to content

Commit

Permalink
hof/flow: allow to config stdin passthrough in os.Exec
Browse files Browse the repository at this point in the history
  • Loading branch information
verdverm committed Jun 19, 2023
1 parent 0953ec4 commit 22c0c8a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions flow/tasks/os/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ func extractIO(ex cue.Value) (Stdin io.Reader, Stdout, Stderr io.Writer, err err
}
Stdin = bytes.NewReader(b)

case cue.BoolKind:
Stdin = os.Stdin

case cue.NullKind:
// do nothing so no Stdin is set

Expand All @@ -248,6 +251,9 @@ func extractIO(ex cue.Value) (Stdin io.Reader, Stdout, Stderr io.Writer, err err
case cue.BytesKind:
Stdout = new(bytes.Buffer)

case cue.BoolKind:
Stdin = os.Stdout

case cue.NullKind:
// do nothing so no Stdin is set

Expand All @@ -269,6 +275,9 @@ func extractIO(ex cue.Value) (Stdin io.Reader, Stdout, Stderr io.Writer, err err
case cue.BytesKind:
Stderr = new(bytes.Buffer)

case cue.BoolKind:
Stdin = os.Stderr

case cue.NullKind:
// do nothing so no Stdin is set

Expand Down
8 changes: 4 additions & 4 deletions flow/tasks/os/schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Exec: {
// stdout captures the output from stdout if it is of type bytes or string.
// The default value of null indicates it is redirected to the stdout of the
// current process.
stdout?: null | string | bytes
stdout?: null | bool | string | bytes

// stderr is like stdout, but for errors.
stderr?: null | string | bytes
stderr?: null | bool | string | bytes

// stdin specifies the input for the process. If stdin is null, the stdin
// stdin specifies the input for the process. If stdin is bool (true or false), the stdin
// of the current process is redirected to this command (the default).
// If it is of typ bytes or string, that input will be used instead.
stdin?: *null | string | bytes
stdin?: *null | bool | string | bytes

// success is set to true when the process terminates with with a zero exit
// code or false otherwise. The user can explicitly specify the value
Expand Down

0 comments on commit 22c0c8a

Please sign in to comment.