Wrapping a executable in a function
Easy function wrapping
- tags
- openfaas
- cli
Contents
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 /usr/local/bin
and I'm changing the fprocess
ENV variable to be xargs gitinfo.rb
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
Async test
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 CALLBACK_URL
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 X-Callback-URL
header where the result is posted.
|
|
Conclustion
Very simple, very little was changed from the below posts below.
Previously
Next