-
Notifications
You must be signed in to change notification settings - Fork 0
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
Allow for pipeline step parameters
to be fully JSON
#161
Conversation
Parameters: map[string]any{ | ||
"method": "${method}", | ||
"url": "https://httpbin.org/${method}?param=${param}", | ||
"data": "{\"key\": \"${value}\", \"${key}\": \"hardcoded_value\"}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data
is currently a json encoded string. this will eventually be changed to be a proper JSON object like headers
requestMethod := step.Parameters["method"] | ||
url := step.Parameters["url"] | ||
requestBody := step.Parameters["data"] | ||
requestMethod := step.Parameters["method"].(string) // TODO: add documentation for parameters, specifically the type for safe type assertion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when creating the pipeline in the frontend, the user doesn't know what parameters are required for the API step type. he also doesn't know if the parameter value should be of what type. we can add both documentation and validation for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Previously,
parameters
was of typemap[string]string
. This meant that the user had to define all parameter values as strings. If they needed maps/lists, they would have to write as json encoded strings and our backend had to further decode these strings into a proper map/list.I've updated the type to now be of type
map[string]any
. This allows the user to write the parameters normally using JSON syntax. However, this requires each step to properly type assert their parameters. I'm thinking we can further improve this and refactor in another PR to add more safety.With this change, I can add in the request headers in a proper JSON object. Same for request data.
Others
Currently, our executor isn't handling panics well. If there is a panic, there won't be any errors shown. I believe this is because the execution is run in a separate goroutine and the panic isn't shown in the main program process.