Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds reqId and propErr to execute #292 #293

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
Loading