Lets look at how to wrap a command line program into a function. We'll assume that you already have an OpenFaaS service running somewhere.
First create the template
Calling the function
I'm going to write a command in
ruby so I'll include things from the
ruby:3.0.1 base image.
The main thing here is that I'm copying the script into
and I'm changing the
fprocess ENV variable to be
which will pass in the standard input as command line arguments.
The script looks like this:
Running without an argument
This is the info file
Passing in arguments
Here we can pass in data to the function:
This is the info file : Hello : world
I'm going to use pipedream.com as a way to collect a response. Go
there and sign up for it if you haven't, and then set the
to be resulting address.
In order to have a function run asyncronously, you need the change the
url to start with
/async-function/ and pass in an
header where the result is posted.
Very simple, very little was changed from the below posts below.