-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow passing multiple
--input-file
s to workflow commands [#351]
The documentation for how to pass multiple arguments was just wrong--`json.Unmarshal()` does not support parsing multi-line JSON inputs as separate values. Fix this by accepting multiple `--input-file` flags, parsing each one separately, and turning each file into a distinct argument. Also, check and throw an error if the user tries to use both `--input` and `--input-file`, since the old behavior--silently ignoring `--input` if `--input-file` is specified--was surprising.
- Loading branch information
1 parent
3f36e1d
commit c824bae
Showing
5 changed files
with
132 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package encodejson | ||
|
||
import ( | ||
"encoding/json" | ||
"time" | ||
|
||
"go.temporal.io/sdk/workflow" | ||
|
||
// TODO(cretz): Remove when tagged | ||
_ "go.temporal.io/sdk/contrib/tools/workflowcheck/determinism" | ||
) | ||
|
||
// Workflow is a Hello World workflow definition. (Ordinarily I would define | ||
// this as a variadic function, but that's not supported currently--see | ||
// https://github.com/temporalio/sdk-go/issues/1114) | ||
func Workflow(ctx workflow.Context, a, b, c, d interface{}) (string, error) { | ||
args := []interface{}{a, b, c, d} | ||
|
||
ao := workflow.ActivityOptions{ | ||
StartToCloseTimeout: 10 * time.Second, | ||
} | ||
ctx = workflow.WithActivityOptions(ctx, ao) | ||
|
||
logger := workflow.GetLogger(ctx) | ||
logger.Info("EncodeJSON workflow started", a, b, c, d) | ||
|
||
result, err := json.Marshal(args) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
logger.Info("EncodeJSON workflow completed", result) | ||
|
||
return string(result), nil | ||
} |