-
Notifications
You must be signed in to change notification settings - Fork 227
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
Add raw body support to python3 templates #207
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR. Just bear in mind to fill out the template i.e. How Has This Been Tested? |
|
||
# distutils.util.strtobool() can throw an exception | ||
def is_true(val): | ||
return val and val.lower() == "true" or val == "1" |
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.
A complete sentence for the doc string would be better, it is clear to me because i recommended strtobool, but a future contributor won't have the context
if you want to use strtobool, you could also do this
def is_true(val):
try:
return distutils.util.strtobool(val)
except:
return false
but either method is good to me 👍
def is_true(val): | ||
return val and val.lower() == "true" or val == "1" | ||
|
||
|
||
def get_stdin(): |
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.
I would guess that get_stdin()
will produce an invalid set of bytes since it is reading lines, I would imagine it should attempt to read an entire payload as bytes. There may not even be any newlines in the binary input - i.e. a JPEG image.
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.
We need to see a test that verifies the input received in the function is a perfect match for the bytes inputted.
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.
If you accept the data in from a HTTP request (curl --data-binary @input.jpg
), then write it to the container in /tmp you can use kubectl cp -n openfaas-fn pod/name ./local-file.jpg
to get the file back and compare for instance.
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.
I have updated this PR and tested with image data and it is working fine. Image file written in container is rendering correctly.
Signed-off-by: Vivek Singh <[email protected]>
Need to cross reference with openfaas/python-flask-template#38 |
This has been handled within |
Sorry to hijack this PR, but I opened a similar, but more extensive issue (#205) in May. In it, I proposed opening a PR with my tried-and-tested solution, but since I got no response on the issue, I didn't at the time. I've now created it as #217. Imho, my solution is less hackish, as it parses standard headers and doesn't require environment variable definition. It also is more extensive in functionality. I'd be happy to propose similar changes to the flask templates (actually have those running privately too). |
Signed-off-by: Vivek Singh [email protected]
Description
Motivation and Context
Which issue(s) this PR fixes
Fixes #
How Has This Been Tested?
This has been tested on my local with kind
Types of changes
Impact to existing users
Checklist:
git commit -s