Skip to content

Commit

Permalink
feat: adds reqId and propErr to execute #292
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Oct 7, 2024
1 parent 2217583 commit 862c905
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions internal/cmd/integrations/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"internal/client/integrations"
"os"

"github.com/google/uuid"
"github.com/spf13/cobra"
)

Expand All @@ -44,6 +45,7 @@ var ExecuteCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) (err error) {
var content []byte
name := cmd.Flag("name").Value.String()
requestID := cmd.Flag("request-id").Value.String()

if executionFile != "" {
if _, err := os.Stat(executionFile); os.IsNotExist(err) {
Expand All @@ -55,18 +57,25 @@ var ExecuteCmd = &cobra.Command{
return err
}
} else if triggerID != "" {
content = []byte(fmt.Sprintf("{\"triggerId\": \"api_trigger/%s\",\"inputParameters\": {}}", triggerID))
if requestID == "" {
requestID = uuid.New().String()
}
content = []byte(fmt.Sprintf("{\"triggerId\": \"api_trigger/%s\",\"doNotPropagateError\": %t,\"requestId\": \"%s\",\"inputParameters\": {}}",
triggerID, doNotPropagateError, requestID))
}

_, err = integrations.Execute(name, content)
return err
},
}

var executionFile, triggerID string
var (
executionFile, triggerID string
doNotPropagateError bool
)

func init() {
var name string
var name, requestID string

ExecuteCmd.Flags().StringVarP(&name, "name", "n",
"", "Integration flow name")
Expand All @@ -77,6 +86,10 @@ func init() {
ExecuteCmd.Flags().StringVarP(&triggerID, "trigger-id", "",
"", "Specify only the trigger id of the integration if there "+
"are no input parameters to be sent. Cannot be combined with -f")
ExecuteCmd.Flags().StringVarP(&requestID, "request-id", "",
"", "This is used to de-dup incoming request")
ExecuteCmd.Flags().BoolVarP(&doNotPropagateError, "do-not-propagate-error", "",
false, "Flag to determine how to should propagate errors")

_ = ExecuteCmd.MarkFlagRequired("name")
}

0 comments on commit 862c905

Please sign in to comment.