From 22c0c8a68b6b10aff00873537e1d987abdb4b7f6 Mon Sep 17 00:00:00 2001 From: Tony Worm Date: Mon, 19 Jun 2023 18:58:12 -0400 Subject: [PATCH] hof/flow: allow to config stdin passthrough in os.Exec --- flow/tasks/os/exec.go | 9 +++++++++ flow/tasks/os/schema.cue | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/flow/tasks/os/exec.go b/flow/tasks/os/exec.go index 67bf8335e..e31e14721 100644 --- a/flow/tasks/os/exec.go +++ b/flow/tasks/os/exec.go @@ -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 @@ -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 @@ -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 diff --git a/flow/tasks/os/schema.cue b/flow/tasks/os/schema.cue index 8fb0532dd..9a85b6dbf 100644 --- a/flow/tasks/os/schema.cue +++ b/flow/tasks/os/schema.cue @@ -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