mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: rename from fnctl (#321)
* fn: rename from fnctl * fn: predicting the release version for installer * fn: predicting the release version for installer
This commit is contained in:
6
Makefile
6
Makefile
@@ -14,8 +14,8 @@ build-docker:
|
|||||||
docker build -t iron/functions:latest .
|
docker build -t iron/functions:latest .
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -v $(shell go list ./... | grep -v vendor | grep -v examples | grep -v tool | grep -v fnctl)
|
go test -v $(shell go list ./... | grep -v vendor | grep -v examples | grep -v tool | grep -v fn)
|
||||||
cd fnctl && $(MAKE) test
|
cd fn && $(MAKE) test
|
||||||
|
|
||||||
test-datastore:
|
test-datastore:
|
||||||
cd api/datastore && go test -v
|
cd api/datastore && go test -v
|
||||||
@@ -25,7 +25,7 @@ test-docker:
|
|||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
-v $(DIR):/go/src/github.com/iron-io/functions \
|
-v $(DIR):/go/src/github.com/iron-io/functions \
|
||||||
-w /go/src/github.com/iron-io/functions iron/go:dev go test \
|
-w /go/src/github.com/iron-io/functions iron/go:dev go test \
|
||||||
-v $(shell go list ./... | grep -v vendor | grep -v examples | grep -v tool | grep -v fnctl | grep -v datastore)
|
-v $(shell go list ./... | grep -v vendor | grep -v examples | grep -v tool | grep -v fn | grep -v datastore)
|
||||||
|
|
||||||
run:
|
run:
|
||||||
./functions
|
./functions
|
||||||
|
|||||||
42
README.md
42
README.md
@@ -8,7 +8,7 @@ Welcome to IronFunctions! The open source serverless platform.
|
|||||||
## What is IronFunctions?
|
## What is IronFunctions?
|
||||||
|
|
||||||
IronFunctions is an open source serverless platform, or as we like to refer to it, Functions as a
|
IronFunctions is an open source serverless platform, or as we like to refer to it, Functions as a
|
||||||
Service (FaaS) platform that you can run anywhere.
|
Service (FaaS) platform that you can run anywhere.
|
||||||
|
|
||||||
* Write once
|
* Write once
|
||||||
* [Any language](docs/faq.md#which-languages-are-supported)
|
* [Any language](docs/faq.md#which-languages-are-supported)
|
||||||
@@ -53,8 +53,8 @@ then the benefits are different, but related.
|
|||||||
* Scaling is simply adding more IronFunctions nodes
|
* Scaling is simply adding more IronFunctions nodes
|
||||||
|
|
||||||
There is a lot more reading you can do on the topic, just search for ["what is serverless"](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=what%20is%20serverless)
|
There is a lot more reading you can do on the topic, just search for ["what is serverless"](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=what%20is%20serverless)
|
||||||
and you'll find plenty of information. We have pretty thorough post on the Iron.io blog called
|
and you'll find plenty of information. We have pretty thorough post on the Iron.io blog called
|
||||||
[What is Serverless Computing and Why is it Important](https://www.iron.io/what-is-serverless-computing/).
|
[What is Serverless Computing and Why is it Important](https://www.iron.io/what-is-serverless-computing/).
|
||||||
|
|
||||||
## Join Our Community
|
## Join Our Community
|
||||||
|
|
||||||
@@ -87,13 +87,13 @@ configuration options [here](docs/options.md). If you are on Windows, check [her
|
|||||||
Install the IronFunctions CLI tool:
|
Install the IronFunctions CLI tool:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -sSL http://get.iron.io/fnctl | sh
|
curl -sSL http://get.iron.io/fn | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
### Write a Function
|
### Write a Function
|
||||||
|
|
||||||
Functions are small, bite sized bits of code that do one simple thing. Forget about monoliths when using functions,
|
Functions are small, bite sized bits of code that do one simple thing. Forget about monoliths when using functions,
|
||||||
just focus on the task that you want the function to perform.
|
just focus on the task that you want the function to perform.
|
||||||
|
|
||||||
The following is a Go function that just returns "Hello ${NAME}!":
|
The following is a Go function that just returns "Hello ${NAME}!":
|
||||||
|
|
||||||
@@ -118,21 +118,21 @@ func main() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Copy and paste the code above into a file called `func.go`, then run the following commands to build your function
|
Copy and paste the code above into a file called `func.go`, then run the following commands to build your function
|
||||||
and deploy it.
|
and deploy it.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# create func.yaml file, replace $USERNAME with your Docker Hub username.
|
# create func.yaml file, replace $USERNAME with your Docker Hub username.
|
||||||
fnctl init $USERNAME/hello
|
fn init $USERNAME/hello
|
||||||
# build the function
|
# build the function
|
||||||
fnctl build
|
fn build
|
||||||
# test it
|
# test it
|
||||||
fnctl run
|
fn run
|
||||||
# push it to Docker Hub
|
# push it to Docker Hub
|
||||||
fnctl push
|
fn push
|
||||||
# create an app
|
# create an app
|
||||||
fnctl apps create myapp
|
fn apps create myapp
|
||||||
# create a route that maps /hello to your new function
|
# create a route that maps /hello to your new function
|
||||||
fnctl routes create myapp /hello
|
fn routes create myapp /hello
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can call your function:
|
Now you can call your function:
|
||||||
@@ -144,18 +144,18 @@ curl http://localhost:8080/r/myapp/hello
|
|||||||
Or surf to it: http://localhost:8080/r/myapp/hello
|
Or surf to it: http://localhost:8080/r/myapp/hello
|
||||||
|
|
||||||
See below for more details. And you can find a bunch of examples in various languages in the [examples](examples/) directory. You can also
|
See below for more details. And you can find a bunch of examples in various languages in the [examples](examples/) directory. You can also
|
||||||
write your functions in AWS's [Lambda format](docs/lambda/README.md).
|
write your functions in AWS's [Lambda format](docs/lambda/README.md).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
This is a more detailed explanation of the main commands you'll use in IronFunctions as a developer.
|
This is a more detailed explanation of the main commands you'll use in IronFunctions as a developer.
|
||||||
|
|
||||||
### Create an Application
|
### Create an Application
|
||||||
|
|
||||||
An application is essentially a grouping of functions, that put together, form an API. Here's how to create an app.
|
An application is essentially a grouping of functions, that put together, form an API. Here's how to create an app.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl apps create myapp
|
fn apps create myapp
|
||||||
```
|
```
|
||||||
|
|
||||||
Or using a cURL:
|
Or using a cURL:
|
||||||
@@ -178,7 +178,7 @@ can use -- yes, you can share functions! The source code for this function is in
|
|||||||
You can read more about [writing your own functions here](docs/writing.md).
|
You can read more about [writing your own functions here](docs/writing.md).
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl routes create myapp /hello iron/hello
|
fn routes create myapp /hello iron/hello
|
||||||
```
|
```
|
||||||
|
|
||||||
Or using cURL:
|
Or using cURL:
|
||||||
@@ -200,10 +200,10 @@ Calling your function is as simple as requesting a URL. Each app has it's own na
|
|||||||
The app `myapp` that we created above along with the `/hello` route we added would be called via the following
|
The app `myapp` that we created above along with the `/hello` route we added would be called via the following
|
||||||
URL: http://localhost:8080/r/myapp/hello
|
URL: http://localhost:8080/r/myapp/hello
|
||||||
|
|
||||||
Either surf to it in your browser or use `fnctl`:
|
Either surf to it in your browser or use `fn`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl call myapp /hello
|
fn call myapp /hello
|
||||||
```
|
```
|
||||||
|
|
||||||
Or using a cURL:
|
Or using a cURL:
|
||||||
@@ -218,7 +218,7 @@ Your function will get the body of the HTTP request via STDIN, and the headers o
|
|||||||
as env vars. You can test a function with the CLI tool:
|
as env vars. You can test a function with the CLI tool:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
echo '{"name":"Johnny"}' | fnctl call myapp /hello
|
echo '{"name":"Johnny"}' | fn call myapp /hello
|
||||||
```
|
```
|
||||||
|
|
||||||
Or using cURL:
|
Or using cURL:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
If you are a developer using IronFunctions through the API, this section is for you.
|
If you are a developer using IronFunctions through the API, this section is for you.
|
||||||
|
|
||||||
* [Quickstart](https://github.com/iron-io/functions#quickstart)
|
* [Quickstart](https://github.com/iron-io/functions#quickstart)
|
||||||
* [fnctl (CLI Tool)](/fnctl/README.md)
|
* [fn (CLI Tool)](/fn/README.md)
|
||||||
* [Writing functions](writing.md)
|
* [Writing functions](writing.md)
|
||||||
* [Writing Lambda functions](lambda/create.md)
|
* [Writing Lambda functions](lambda/create.md)
|
||||||
* [Function file (func.yaml)](function-file.md)
|
* [Function file (func.yaml)](function-file.md)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ environment variables.
|
|||||||
Note: Route level configuration overrides app level configuration.
|
Note: Route level configuration overrides app level configuration.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl apps create --config k1=v1 --config k2=v2 myapp
|
fn apps create --config k1=v1 --config k2=v2 myapp
|
||||||
```
|
```
|
||||||
|
|
||||||
Or using a cURL:
|
Or using a cURL:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Function files
|
# Function files
|
||||||
|
|
||||||
Functions files are used to assist fnctl to help you when creating functions.
|
Functions files are used to assist fn to help you when creating functions.
|
||||||
|
|
||||||
The files can be named as:
|
The files can be named as:
|
||||||
|
|
||||||
@@ -49,5 +49,5 @@ setup. These configuration options shall override application configuration
|
|||||||
during functions execution.
|
during functions execution.
|
||||||
|
|
||||||
`build` (optional) is an array of shell calls which are used to helping building
|
`build` (optional) is an array of shell calls which are used to helping building
|
||||||
the image. These calls are executed before `fnctl` calls `docker build` and
|
the image. These calls are executed before `fn` calls `docker build` and
|
||||||
`docker push`.
|
`docker push`.
|
||||||
@@ -25,7 +25,7 @@ write a simple function and have an "executable" ready to go.
|
|||||||
## How does it work?
|
## How does it work?
|
||||||
|
|
||||||
We provide base Docker images for the various runtimes that AWS Lambda
|
We provide base Docker images for the various runtimes that AWS Lambda
|
||||||
supports. The `fnctl` tool helps package up your Lambda function into
|
supports. The `fn` tool helps package up your Lambda function into
|
||||||
a Docker image layered on the base image. We provide a bootstrap script and
|
a Docker image layered on the base image. We provide a bootstrap script and
|
||||||
utilities that provide a AWS Lambda environment to your code. You can then run
|
utilities that provide a AWS Lambda environment to your code. You can then run
|
||||||
the Docker image on any platform that supports Docker. This allows you to
|
the Docker image on any platform that supports Docker. This allows you to
|
||||||
@@ -35,7 +35,7 @@ easily move Lambda functions to any cloud provider, or host it yourself.
|
|||||||
|
|
||||||
Write, package and run your Lambda functions with our [Getting started
|
Write, package and run your Lambda functions with our [Getting started
|
||||||
guide](./getting-started.md). [Here is the environment](./environment.md) that
|
guide](./getting-started.md). [Here is the environment](./environment.md) that
|
||||||
Lambda provides. `fnctl lambda` lists the commands to work with Lambda
|
Lambda provides. `fn lambda` lists the commands to work with Lambda
|
||||||
functions locally.
|
functions locally.
|
||||||
|
|
||||||
You can [import](./import.md) existing Lambda functions hosted on Amazon!
|
You can [import](./import.md) existing Lambda functions hosted on Amazon!
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ This can be done as follows:
|
|||||||
export aws_access_key_id=<access-key>
|
export aws_access_key_id=<access-key>
|
||||||
export aws_secret_access_key=<secret_key>
|
export aws_secret_access_key=<secret_key>
|
||||||
|
|
||||||
./fnctl lambda create-function <user>/s3 nodejs example.run examples/s3/example.js examples/s3/example-payload.json --config aws_access_key_id --config aws_secret_access_key
|
./fn lambda create-function <user>/s3 nodejs example.run examples/s3/example.js examples/s3/example-payload.json --config aws_access_key_id --config aws_secret_access_key
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./fnctl lambda create-function <user>/s3 nodejs example.run ../../lambda/examples/s3/example.js ../../lambda/examples/s3/example-payload.json --config aws_access_key_id=<access-key> --config aws_secret_access_key=<secret_key>
|
./fn lambda create-function <user>/s3 nodejs example.run ../../lambda/examples/s3/example.js ../../lambda/examples/s3/example-payload.json --config aws_access_key_id=<access-key> --config aws_secret_access_key=<secret_key>
|
||||||
```
|
```
|
||||||
|
|
||||||
The various AWS SDKs will automatically pick these up.
|
The various AWS SDKs will automatically pick these up.
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# Creating Docker images out of Lambda functions
|
# Creating Docker images out of Lambda functions
|
||||||
Docker images created by running the `create-function` subcommand on a Lambda function are ready to execute.
|
Docker images created by running the `create-function` subcommand on a Lambda function are ready to execute.
|
||||||
|
|
||||||
You can convert any Lambda function of type nodejs 0.10, python 2.7 and Java 8 into an
|
You can convert any Lambda function of type nodejs 0.10, python 2.7 and Java 8 into an
|
||||||
IronFunction compatible Docker Image as follows:
|
IronFunction compatible Docker Image as follows:
|
||||||
```bash
|
```bash
|
||||||
fnctl lambda create-function <name> <runtime> <handler> <files...>
|
fn lambda create-function <name> <runtime> <handler> <files...>
|
||||||
```
|
```
|
||||||
|
|
||||||
* name: the name of the created docker image which should have the format `<username>/<image-name>`
|
* name: the name of the created docker image which should have the format `<username>/<image-name>`
|
||||||
@@ -17,6 +17,6 @@ fnctl lambda create-function <name> <runtime> <handler> <files...>
|
|||||||
|
|
||||||
e.g:
|
e.g:
|
||||||
```bash
|
```bash
|
||||||
fnctl lambda create-function irontest/node-exec:1 nodejs node_exec.handler node_exec.js
|
fn lambda create-function irontest/node-exec:1 nodejs node_exec.handler node_exec.js
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
This guide will walk you through creating and testing a simple Lambda function.
|
This guide will walk you through creating and testing a simple Lambda function.
|
||||||
|
|
||||||
We need the the `fnctl` tool for the rest of this guide. You can install it
|
We need the the `fn` tool for the rest of this guide. You can install it
|
||||||
by following [these instructions](https://github.com/iron-io/function/fnctl).
|
by following [these instructions](https://github.com/iron-io/function/fn).
|
||||||
|
|
||||||
*For this getting started we are assuming you already have working lambda function code available, if not head to the [import instructions] (import.md) and skip the next section.*
|
*For this getting started we are assuming you already have working lambda function code available, if not head to the [import instructions] (import.md) and skip the next section.*
|
||||||
|
|
||||||
@@ -13,21 +13,21 @@ Let's convert the `hello_world` AWS Lambda example to Docker.
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
def my_handler(event, context):
|
def my_handler(event, context):
|
||||||
message = 'Hello {} {}!'.format(event['first_name'],
|
message = 'Hello {} {}!'.format(event['first_name'],
|
||||||
event['last_name'])
|
event['last_name'])
|
||||||
return {
|
return {
|
||||||
'message' : message
|
'message' : message
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Create an empty directory for your project and save this code in a file called
|
Create an empty directory for your project and save this code in a file called
|
||||||
`hello_world.py`.
|
`hello_world.py`.
|
||||||
|
|
||||||
Now let's use `fnctl`'s Lambda functionality to create a Docker image. We can
|
Now let's use `fn`'s Lambda functionality to create a Docker image. We can
|
||||||
then run the Docker image with a payload to execute the Lambda function.
|
then run the Docker image with a payload to execute the Lambda function.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ fnctl lambda create-function irontest/hello_world:1 python2.7 hello_world.my_handler hello_world.py
|
$ fn lambda create-function irontest/hello_world:1 python2.7 hello_world.my_handler hello_world.py
|
||||||
Creating directory: irontest/hello_world:1 ... OK
|
Creating directory: irontest/hello_world:1 ... OK
|
||||||
Creating Dockerfile: irontest/hello_world:1/Dockerfile ... OK
|
Creating Dockerfile: irontest/hello_world:1/Dockerfile ... OK
|
||||||
Copying file: irontest/hello_world/hello_world:1.py ... OK
|
Copying file: irontest/hello_world/hello_world:1.py ... OK
|
||||||
@@ -40,23 +40,23 @@ As you can see, this is very similar to creating a Lambda function using the
|
|||||||
your deployment environment to use different versions. The handler is
|
your deployment environment to use different versions. The handler is
|
||||||
the name of the function to run, in the form that python expects
|
the name of the function to run, in the form that python expects
|
||||||
(`module.function`). Where you would package the files into a `.zip` to upload
|
(`module.function`). Where you would package the files into a `.zip` to upload
|
||||||
to Lambda, we just pass the list of files to `fnctl`.
|
to Lambda, we just pass the list of files to `fn`.
|
||||||
|
|
||||||
## Publishing the function to IronFunctions
|
## Publishing the function to IronFunctions
|
||||||
|
|
||||||
Next we want to publish the function to our IronFunctions
|
Next we want to publish the function to our IronFunctions
|
||||||
```sh
|
```sh
|
||||||
$ fnctl publish -v -f -d ./irontest
|
$ fn publish -v -f -d ./irontest
|
||||||
publishing irontest/hello_world:1/function.yaml
|
publishing irontest/hello_world:1/function.yaml
|
||||||
Sending build context to Docker daemon 4.096 kB
|
Sending build context to Docker daemon 4.096 kB
|
||||||
Step 1 : FROM iron/lambda-python2.7
|
Step 1 : FROM iron/lambda-python2.7
|
||||||
latest: Pulling from iron/lambda-python2.7
|
latest: Pulling from iron/lambda-python2.7
|
||||||
c52e3ed763ff: Pull complete
|
c52e3ed763ff: Pull complete
|
||||||
789cf808491a: Pull complete
|
789cf808491a: Pull complete
|
||||||
d1b635efed57: Pull complete
|
d1b635efed57: Pull complete
|
||||||
fe23c3dbcfa8: Pull complete
|
fe23c3dbcfa8: Pull complete
|
||||||
63c874a9687e: Pull complete
|
63c874a9687e: Pull complete
|
||||||
a6d462dae1df: Pull complete
|
a6d462dae1df: Pull complete
|
||||||
Digest: sha256:c5dde3bf3be776c0f6b909d4ad87255a0af9b6696831fbe17c5f659655a0494a
|
Digest: sha256:c5dde3bf3be776c0f6b909d4ad87255a0af9b6696831fbe17c5f659655a0494a
|
||||||
Status: Downloaded newer image for iron/lambda-python2.7:latest
|
Status: Downloaded newer image for iron/lambda-python2.7:latest
|
||||||
---> 66d3adf47835
|
---> 66d3adf47835
|
||||||
@@ -69,15 +69,15 @@ Next we want to publish the function to our IronFunctions
|
|||||||
Removing intermediate container 318da1bba060
|
Removing intermediate container 318da1bba060
|
||||||
Successfully built db9b9644168e
|
Successfully built db9b9644168e
|
||||||
The push refers to a repository [docker.io/irontest/hello_world:1]
|
The push refers to a repository [docker.io/irontest/hello_world:1]
|
||||||
5d9d142e21b2: Pushed
|
5d9d142e21b2: Pushed
|
||||||
11d8145d6038: Layer already exists
|
11d8145d6038: Layer already exists
|
||||||
23885f85dbd0: Layer already exists
|
23885f85dbd0: Layer already exists
|
||||||
6a350a8d14ee: Layer already exists
|
6a350a8d14ee: Layer already exists
|
||||||
e67f7ef625c5: Layer already exists
|
e67f7ef625c5: Layer already exists
|
||||||
321db514ef85: Layer already exists
|
321db514ef85: Layer already exists
|
||||||
6102f0d2ad33: Layer already exists
|
6102f0d2ad33: Layer already exists
|
||||||
latest: digest: sha256:5926ff413f134fa353e4b42f2d4a0d2d4f5b3a39489cfdf6dd5b4a63c4e40dee size: 1784
|
latest: digest: sha256:5926ff413f134fa353e4b42f2d4a0d2d4f5b3a39489cfdf6dd5b4a63c4e40dee size: 1784
|
||||||
updating API with appName: irontest route: /hello_world:1 image: irontest/hello_world:1
|
updating API with appName: irontest route: /hello_world:1 image: irontest/hello_world:1
|
||||||
path result
|
path result
|
||||||
irontest/hello_world:1/function.yaml done
|
irontest/hello_world:1/function.yaml done
|
||||||
```
|
```
|
||||||
@@ -100,22 +100,22 @@ The `test-function` subcommand can launch the Dockerized function with the
|
|||||||
right parameters.
|
right parameters.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ fnctl lambda test-function irontest/hello_world:1 --payload '{ "first_name": "Jon", "last_name": "Snow" }'
|
$ fn lambda test-function irontest/hello_world:1 --payload '{ "first_name": "Jon", "last_name": "Snow" }'
|
||||||
{"message": "Hello Jon Snow!"}
|
{"message": "Hello Jon Snow!"}
|
||||||
```
|
```
|
||||||
|
|
||||||
You should see the output.
|
You should see the output.
|
||||||
|
|
||||||
## Calling the function from IronFunctions
|
## Calling the function from IronFunctions
|
||||||
|
|
||||||
The `fnctl call` command can call the published version with a given payload.
|
The `fn call` command can call the published version with a given payload.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ echo '{ "first_name": "Jon", "last_name": "Snow" }' | ./fnctl call irontest /hello_world:1
|
$ echo '{ "first_name": "Jon", "last_name": "Snow" }' | ./fn call irontest /hello_world:1
|
||||||
{"message": "Hello Jon Snow!"}
|
{"message": "Hello Jon Snow!"}
|
||||||
```
|
```
|
||||||
|
|
||||||
You should see the output.
|
You should see the output.
|
||||||
|
|
||||||
|
|
||||||
## Commands documentation
|
## Commands documentation
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Import existing AWS Lambda functions
|
Import existing AWS Lambda functions
|
||||||
====================================
|
====================================
|
||||||
|
|
||||||
The [fnctl](https://github.com/iron-io/functions/fnctl/) tool includes a set of
|
The [fn](https://github.com/iron-io/functions/fn/) tool includes a set of
|
||||||
commands to act on Lambda functions. Most of these are described in
|
commands to act on Lambda functions. Most of these are described in
|
||||||
[getting-started](./getting-started.md). One more subcommand is `aws-import`.
|
[getting-started](./getting-started.md). One more subcommand is `aws-import`.
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ region. You can use the `aws` tool to set this up. Full instructions are in the
|
|||||||
The aws-import command is constructed as follows:
|
The aws-import command is constructed as follows:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
fnctl lambda aws-import <arn> <region> <image>
|
fn lambda aws-import <arn> <region> <image>
|
||||||
```
|
```
|
||||||
|
|
||||||
* arn: describes the ARN formats which uniquely identify the AWS lambda resource
|
* arn: describes the ARN formats which uniquely identify the AWS lambda resource
|
||||||
@@ -33,7 +33,7 @@ fnctl lambda aws-import <arn> <region> <image>
|
|||||||
Assuming you have a lambda with the following arn `arn:aws:lambda:us-west-2:123141564251:function:my-function`, the following command:
|
Assuming you have a lambda with the following arn `arn:aws:lambda:us-west-2:123141564251:function:my-function`, the following command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl lambda aws-import arn:aws:lambda:us-west-2:123141564251:function:my-function us-east-1 user/my-function
|
fn lambda aws-import arn:aws:lambda:us-west-2:123141564251:function:my-function us-east-1 user/my-function
|
||||||
```
|
```
|
||||||
|
|
||||||
will import the function code from the region `us-east-1` to a directory called `./user/my-function`. Inside the directory you will find the `function.yml`, `Dockerfile`, and all the files needed for running the function.
|
will import the function code from the region `us-east-1` to a directory called `./user/my-function`. Inside the directory you will find the `function.yml`, `Dockerfile`, and all the files needed for running the function.
|
||||||
@@ -50,6 +50,6 @@ by passing `--version <version>.`
|
|||||||
|
|
||||||
You can then publish the imported lambda as follows:
|
You can then publish the imported lambda as follows:
|
||||||
```
|
```
|
||||||
./fnctl publish -d ./user/my-function
|
./fn publish -d ./user/my-function
|
||||||
````
|
````
|
||||||
Now the function can be reached via ```http://$HOSTNAME/r/user/my-function```
|
Now the function can be reached via ```http://$HOSTNAME/r/user/my-function```
|
||||||
@@ -11,7 +11,7 @@ docker run
|
|||||||
|
|
||||||
An example of a valid `test-function` command would look as follows:
|
An example of a valid `test-function` command would look as follows:
|
||||||
```
|
```
|
||||||
fnctl lambda test-function user/my-function --payload='{"firstName":"John", "lastName":"Yo" }'
|
fn lambda test-function user/my-function --payload='{"firstName":"John", "lastName":"Yo" }'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Payload
|
## Payload
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ Packaging a function has two parts:
|
|||||||
* Create a Docker image for your function with an ENTRYPOINT
|
* Create a Docker image for your function with an ENTRYPOINT
|
||||||
* Push your Docker image to a registry (Docker Hub by default)
|
* Push your Docker image to a registry (Docker Hub by default)
|
||||||
|
|
||||||
Once it's pushed to a registry, you can use it by referencing it when adding a route.
|
Once it's pushed to a registry, you can use it by referencing it when adding a route.
|
||||||
|
|
||||||
## Using fnctl
|
## Using fn
|
||||||
|
|
||||||
This is the easiest way to build, package and publish your functions.
|
This is the easiest way to build, package and publish your functions.
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ This is the easiest way to build, package and publish your functions.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
### Creating an image
|
### Creating an image
|
||||||
|
|
||||||
@@ -39,10 +39,10 @@ docker run --rm -v "$PWD":/go/src/$FUNCPKG -w /go/src/$FUNCPKG iron/go:dev go bu
|
|||||||
docker build -t $USERNAME/myfunction .
|
docker build -t $USERNAME/myfunction .
|
||||||
```
|
```
|
||||||
|
|
||||||
Or using [fnctl](../fnctl/README.md):
|
Or using [fn](../fn/README.md):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl build
|
fn build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Push your image
|
### Push your image
|
||||||
@@ -50,11 +50,11 @@ fnctl build
|
|||||||
This part is simple:
|
This part is simple:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker push $USERNAME/myfunction
|
docker push $USERNAME/myfunction
|
||||||
```
|
```
|
||||||
|
|
||||||
Or using [fnctl](../fnctl/README.md):
|
Or using [fn](../fn/README.md):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl push
|
fn push
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ This example will show you how to test and deploy Go (Golang) code to IronFuncti
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
# create your func.yaml file
|
# create your func.yaml file
|
||||||
fnctl init <YOUR_DOCKERHUB_USERNAME>/hello
|
fn init <YOUR_DOCKERHUB_USERNAME>/hello
|
||||||
# build the function
|
# build the function
|
||||||
fnctl build
|
fn build
|
||||||
# test it
|
# test it
|
||||||
cat hello.payload.json | fnctl run
|
cat hello.payload.json | fn run
|
||||||
# push it to Docker Hub
|
# push it to Docker Hub
|
||||||
fnctl push
|
fn push
|
||||||
# Create a route to this function on IronFunctions
|
# Create a route to this function on IronFunctions
|
||||||
fnctl routes create myapp /hello
|
fn routes create myapp /hello
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can call your function on IronFunctions:
|
Now you can call your function on IronFunctions:
|
||||||
@@ -23,5 +23,5 @@ curl -H "Content-Type: application/json" -X POST -d @hello.payload.json http://l
|
|||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
Be sure you're dependencies are in the `vendor/` directory and that's it.
|
Be sure you're dependencies are in the `vendor/` directory and that's it.
|
||||||
|
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ This example will show you how to test and deploy a Node function to IronFunctio
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
# create your func.yaml file
|
# create your func.yaml file
|
||||||
fnctl init <YOUR_DOCKERHUB_USERNAME>/hello
|
fn init <YOUR_DOCKERHUB_USERNAME>/hello
|
||||||
# build the function
|
# build the function
|
||||||
fnctl build
|
fn build
|
||||||
# test it
|
# test it
|
||||||
cat hello.payload.json | fnctl run
|
cat hello.payload.json | fn run
|
||||||
# push it to Docker Hub for use with IronFunctions
|
# push it to Docker Hub for use with IronFunctions
|
||||||
fnctl push
|
fn push
|
||||||
# Create a route to this function on IronFunctions
|
# Create a route to this function on IronFunctions
|
||||||
fnctl routes create myapp /hello
|
fn routes create myapp /hello
|
||||||
```
|
```
|
||||||
|
|
||||||
Now surf to: http://localhost:8080/r/myapp/hello
|
Now surf to: http://localhost:8080/r/myapp/hello
|
||||||
@@ -27,7 +27,7 @@ Run:
|
|||||||
docker run --rm -v "$PWD":/function -w /function iron/node:dev npm install
|
docker run --rm -v "$PWD":/function -w /function iron/node:dev npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
Then everything should work.
|
Then everything should work.
|
||||||
|
|
||||||
For example, using the `package.json` file in this directory which includes the [request](https://www.npmjs.com/package/request) package, you can add this to func.js and it will work:
|
For example, using the `package.json` file in this directory which includes the [request](https://www.npmjs.com/package/request) package, you can add this to func.js and it will work:
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ For example, using the `package.json` file in this directory which includes the
|
|||||||
var request = require('request');
|
var request = require('request');
|
||||||
request('http://www.google.com', function (error, response, body) {
|
request('http://www.google.com', function (error, response, body) {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
console.log(body) // Show the HTML for the Google homepage.
|
console.log(body) // Show the HTML for the Google homepage.
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ the moment you try to test this function.
|
|||||||
### 2. Build:
|
### 2. Build:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl publish
|
fn publish
|
||||||
```
|
```
|
||||||
|
|
||||||
`-v` is optional, but it allows you to see how this function is being built.
|
`-v` is optional, but it allows you to see how this function is being built.
|
||||||
@@ -31,7 +31,7 @@ fnctl publish
|
|||||||
Now you can start jobs on your function. Let's quickly queue up a job to try it out.
|
Now you can start jobs on your function. Let's quickly queue up a job to try it out.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cat hello.payload.json | fnctl run phpapp /hello
|
cat hello.payload.json | fn run phpapp /hello
|
||||||
```
|
```
|
||||||
|
|
||||||
Here's a curl example to show how easy it is to do in any language:
|
Here's a curl example to show how easy it is to do in any language:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ the moment you try to test this function.
|
|||||||
### 2. Build:
|
### 2. Build:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl publish
|
fn publish
|
||||||
```
|
```
|
||||||
|
|
||||||
`-v` is optional, but it allows you to see how this function is being built.
|
`-v` is optional, but it allows you to see how this function is being built.
|
||||||
@@ -32,7 +32,7 @@ fnctl publish
|
|||||||
Now you can start jobs on your function. Let's quickly queue up a job to try it out.
|
Now you can start jobs on your function. Let's quickly queue up a job to try it out.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cat hello.payload.json | fnctl run pythonapp /hello
|
cat hello.payload.json | fn run pythonapp /hello
|
||||||
```
|
```
|
||||||
|
|
||||||
Here's a curl example to show how easy it is to do in any language:
|
Here's a curl example to show how easy it is to do in any language:
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ This example will show you how to test and deploy a Ruby function to IronFunctio
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
# create your func.yaml file
|
# create your func.yaml file
|
||||||
fnctl init <YOUR_DOCKERHUB_USERNAME>/hello
|
fn init <YOUR_DOCKERHUB_USERNAME>/hello
|
||||||
# install dependencies, we need the json gem to run this
|
# install dependencies, we need the json gem to run this
|
||||||
docker run --rm -v "$PWD":/worker -w /worker iron/ruby:dev bundle install --standalone --clean
|
docker run --rm -v "$PWD":/worker -w /worker iron/ruby:dev bundle install --standalone --clean
|
||||||
# build the function
|
# build the function
|
||||||
fnctl build
|
fn build
|
||||||
# test it
|
# test it
|
||||||
cat hello.payload.json | fnctl run
|
cat hello.payload.json | fn run
|
||||||
# push it to Docker Hub for use with IronFunctions
|
# push it to Docker Hub for use with IronFunctions
|
||||||
fnctl push
|
fn push
|
||||||
# Create a route to this function on IronFunctions
|
# Create a route to this function on IronFunctions
|
||||||
fnctl routes create myapp /hello
|
fn routes create myapp /hello
|
||||||
```
|
```
|
||||||
|
|
||||||
Now surf to: http://localhost:8080/r/myapp/hello
|
Now surf to: http://localhost:8080/r/myapp/hello
|
||||||
|
|||||||
3
fn/.gitignore
vendored
Normal file
3
fn/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fn
|
||||||
|
vendor/
|
||||||
|
/fn.exe
|
||||||
@@ -7,7 +7,7 @@ RUN apk --update upgrade && \
|
|||||||
rm -rf /var/cache/apk/*
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
COPY fnctl /
|
COPY fn /
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
19
fn/Makefile
Normal file
19
fn/Makefile
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
all: vendor
|
||||||
|
go build -o fn
|
||||||
|
./fn
|
||||||
|
|
||||||
|
docker: vendor
|
||||||
|
GOOS=linux go build -o fn
|
||||||
|
docker build -t iron/fn .
|
||||||
|
docker push iron/fn
|
||||||
|
|
||||||
|
vendor:
|
||||||
|
glide install -v
|
||||||
|
|
||||||
|
test:
|
||||||
|
go test -v $(shell glide nv)
|
||||||
|
|
||||||
|
release: docker
|
||||||
|
GOOS=linux go build -o fn_linux
|
||||||
|
GOOS=darwin go build -o fn_mac
|
||||||
|
GOOS=windows go build -o fn.exe
|
||||||
@@ -12,43 +12,43 @@ if you are using Node, put the code that you want to execute in the file `func.j
|
|||||||
Run:
|
Run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl init <DOCKER_HUB_USERNAME>/<FUNCTION_NAME>
|
fn init <DOCKER_HUB_USERNAME>/<FUNCTION_NAME>
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to override the convention with configuration, you can do that as well using:
|
If you want to override the convention with configuration, you can do that as well using:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl init [--runtime node] [--entrypoint "node hello.js"] <DOCKER_HUB_USERNAME>/<FUNCTION_NAME>
|
fn init [--runtime node] [--entrypoint "node hello.js"] <DOCKER_HUB_USERNAME>/<FUNCTION_NAME>
|
||||||
```
|
```
|
||||||
|
|
||||||
Or, if you want full control, just make a Dockerfile. If `init` finds a Dockerfile, it will use that instead of runtime and entrypoint.
|
Or, if you want full control, just make a Dockerfile. If `init` finds a Dockerfile, it will use that instead of runtime and entrypoint.
|
||||||
|
|
||||||
### Build, Bump, Run, Push
|
### Build, Bump, Run, Push
|
||||||
|
|
||||||
`fnctl` provides a few commands you'll use while creating and updating your functions: `build`, `bump`, `run` and `push`.
|
`fn` provides a few commands you'll use while creating and updating your functions: `build`, `bump`, `run` and `push`.
|
||||||
|
|
||||||
Build will build the image for your function.
|
Build will build the image for your function.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl build
|
fn build
|
||||||
```
|
```
|
||||||
|
|
||||||
Bump will bump the version number in your func.yaml file. Versions must be in [semver](http://semver.org/) format.
|
Bump will bump the version number in your func.yaml file. Versions must be in [semver](http://semver.org/) format.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl bump
|
fn bump
|
||||||
```
|
```
|
||||||
|
|
||||||
Run will help you test your function. Functions read input from STDIN, so you can pipe the payload into the function like this:
|
Run will help you test your function. Functions read input from STDIN, so you can pipe the payload into the function like this:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cat `payload.json` | fnctl run
|
cat `payload.json` | fn run
|
||||||
```
|
```
|
||||||
|
|
||||||
Push will push the function image to Docker Hub.
|
Push will push the function image to Docker Hub.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fnctl push
|
fn push
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using the API
|
## Using the API
|
||||||
@@ -56,28 +56,28 @@ fnctl push
|
|||||||
You can operate IronFunctions from the command line.
|
You can operate IronFunctions from the command line.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ fnctl apps # list apps
|
$ fn apps # list apps
|
||||||
myapp
|
myapp
|
||||||
|
|
||||||
$ fnctl apps create otherapp # create new app
|
$ fn apps create otherapp # create new app
|
||||||
otherapp created
|
otherapp created
|
||||||
|
|
||||||
$ fnctl apps describe otherapp # describe an app
|
$ fn apps describe otherapp # describe an app
|
||||||
app: otherapp
|
app: otherapp
|
||||||
no specific configuration
|
no specific configuration
|
||||||
|
|
||||||
$ fnctl apps
|
$ fn apps
|
||||||
myapp
|
myapp
|
||||||
otherapp
|
otherapp
|
||||||
|
|
||||||
$ fnctl routes myapp # list routes of an app
|
$ fn routes myapp # list routes of an app
|
||||||
path image
|
path image
|
||||||
/hello iron/hello
|
/hello iron/hello
|
||||||
|
|
||||||
$ fnctl routes create otherapp /hello iron/hello # create route
|
$ fn routes create otherapp /hello iron/hello # create route
|
||||||
/hello created with iron/hello
|
/hello created with iron/hello
|
||||||
|
|
||||||
$ fnctl routes delete otherapp hello # delete route
|
$ fn routes delete otherapp hello # delete route
|
||||||
/hello deleted
|
/hello deleted
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -88,13 +88,13 @@ routes' with an appropriate flag, `config`.
|
|||||||
|
|
||||||
Thus a more complete example of an application creation will look like:
|
Thus a more complete example of an application creation will look like:
|
||||||
```sh
|
```sh
|
||||||
fnctl apps create --config DB_URL=http://example.org/ otherapp
|
fn apps create --config DB_URL=http://example.org/ otherapp
|
||||||
```
|
```
|
||||||
|
|
||||||
`--config` is a map of values passed to the route runtime in the form of
|
`--config` is a map of values passed to the route runtime in the form of
|
||||||
environment variables.
|
environment variables.
|
||||||
|
|
||||||
Repeated calls to `fnctl apps create` will trigger an update of the given
|
Repeated calls to `fn apps create` will trigger an update of the given
|
||||||
route, thus you will be able to change any of these attributes later in time
|
route, thus you will be able to change any of these attributes later in time
|
||||||
if necessary.
|
if necessary.
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ choices are: `memory`, `type` and `config`.
|
|||||||
|
|
||||||
Thus a more complete example of route creation will look like:
|
Thus a more complete example of route creation will look like:
|
||||||
```sh
|
```sh
|
||||||
fnctl routes create --memory 256 --type async --config DB_URL=http://example.org/ otherapp /hello iron/hello
|
fn routes create --memory 256 --type async --config DB_URL=http://example.org/ otherapp /hello iron/hello
|
||||||
```
|
```
|
||||||
|
|
||||||
`--memory` is number of usable MiB for this function. If during the execution it
|
`--memory` is number of usable MiB for this function. If during the execution it
|
||||||
@@ -118,18 +118,18 @@ dispatches a new request, gets a task ID back and closes the HTTP connection.
|
|||||||
`--config` is a map of values passed to the route runtime in the form of
|
`--config` is a map of values passed to the route runtime in the form of
|
||||||
environment variables.
|
environment variables.
|
||||||
|
|
||||||
Repeated calls to `fnctl route create` will trigger an update of the given
|
Repeated calls to `fn route create` will trigger an update of the given
|
||||||
route, thus you will be able to change any of these attributes later in time
|
route, thus you will be able to change any of these attributes later in time
|
||||||
if necessary.
|
if necessary.
|
||||||
|
|
||||||
## Changing target host
|
## Changing target host
|
||||||
|
|
||||||
`fnctl` is configured by default to talk http://localhost:8080.
|
`fn` is configured by default to talk http://localhost:8080.
|
||||||
You may reconfigure it to talk to a remote installation by updating a local
|
You may reconfigure it to talk to a remote installation by updating a local
|
||||||
environment variable (`$API_URL`):
|
environment variable (`$API_URL`):
|
||||||
```sh
|
```sh
|
||||||
$ export API_URL="http://myfunctions.example.org/"
|
$ export API_URL="http://myfunctions.example.org/"
|
||||||
$ fnctl ...
|
$ fn ...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Publish
|
## Publish
|
||||||
@@ -139,7 +139,7 @@ functions, rebuild them and push them to Docker Hub and update them in
|
|||||||
IronFunction.
|
IronFunction.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ fnctl publish
|
$ fn publish
|
||||||
path result
|
path result
|
||||||
/app/hello done
|
/app/hello done
|
||||||
/app/hello-sync error: no Dockerfile found for this function
|
/app/hello-sync error: no Dockerfile found for this function
|
||||||
@@ -173,7 +173,7 @@ following this convention:
|
|||||||
It will render this pattern of updates:
|
It will render this pattern of updates:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ fnctl publish
|
$ fn publish
|
||||||
path result
|
path result
|
||||||
/myapp/route1/subroute1 done
|
/myapp/route1/subroute1 done
|
||||||
/other/route1 done
|
/other/route1 done
|
||||||
@@ -183,8 +183,8 @@ It means that first subdirectory are always considered app names (e.g. `myapp`
|
|||||||
and `other`), each subdirectory of these firsts are considered part of the route
|
and `other`), each subdirectory of these firsts are considered part of the route
|
||||||
(e.g. `route1/subroute1`).
|
(e.g. `route1/subroute1`).
|
||||||
|
|
||||||
`fnctl publish` expects that each directory to contain a file `func.yaml`
|
`fn publish` expects that each directory to contain a file `func.yaml`
|
||||||
which instructs `fnctl` on how to act with that particular update, and a
|
which instructs `fn` on how to act with that particular update, and a
|
||||||
Dockerfile which it is going to use to build the image and push to Docker Hub.
|
Dockerfile which it is going to use to build the image and push to Docker Hub.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
@@ -196,9 +196,9 @@ done, run:
|
|||||||
$ make
|
$ make
|
||||||
```
|
```
|
||||||
|
|
||||||
It will build fnctl compatible with your local environment. You can test this
|
It will build fn compatible with your local environment. You can test this
|
||||||
CLI, right away with:
|
CLI, right away with:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ./fnctl
|
$ ./fn
|
||||||
```
|
```
|
||||||
@@ -21,7 +21,7 @@ func apps() cli.Command {
|
|||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "apps",
|
Name: "apps",
|
||||||
Usage: "list apps",
|
Usage: "list apps",
|
||||||
ArgsUsage: "fnctl apps",
|
ArgsUsage: "fn apps",
|
||||||
Action: a.list,
|
Action: a.list,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
{
|
{
|
||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/iron-io/functions/fnctl/langs"
|
"github.com/iron-io/functions/fn/langs"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -4,4 +4,4 @@ HOST=$(/sbin/ip route|awk '/default/ { print $3 }')
|
|||||||
|
|
||||||
echo "$HOST default localhost localhost.local" > /etc/hosts
|
echo "$HOST default localhost localhost.local" > /etc/hosts
|
||||||
|
|
||||||
/fnctl "$@"
|
/fn "$@"
|
||||||
0
fnctl/glide.lock → fn/glide.lock
generated
0
fnctl/glide.lock → fn/glide.lock
generated
@@ -1,4 +1,4 @@
|
|||||||
package: github.com/iron-io/functions/fnctl
|
package: github.com/iron-io/functions/fn
|
||||||
import:
|
import:
|
||||||
- package: github.com/docker/docker
|
- package: github.com/docker/docker
|
||||||
subpackages:
|
subpackages:
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
usage: fnctl init <name>
|
usage: fn init <name>
|
||||||
|
|
||||||
If there's a Dockerfile found, this will generate the basic file with just the image name. exit
|
If there's a Dockerfile found, this will generate the basic file with just the image name. exit
|
||||||
It will then try to decipher the runtime based on the files in the current directory, if it can't figure it out, it will ask.
|
It will then try to decipher the runtime based on the files in the current directory, if it can't figure it out, it will ask.
|
||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/iron-io/functions/fnctl/langs"
|
"github.com/iron-io/functions/fn/langs"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Install script to install fnctl
|
# Install script to install fn
|
||||||
|
|
||||||
release='0.1.2'
|
release='0.1.15'
|
||||||
|
|
||||||
command_exists() {
|
command_exists() {
|
||||||
command -v "$@" > /dev/null 2>&1
|
command -v "$@" > /dev/null 2>&1
|
||||||
@@ -19,8 +19,8 @@ case "$(uname -m)" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if command_exists fnctl ; then
|
if command_exists fn ; then
|
||||||
echo >&2 'Warning: "fnctl" command appears to already exist.'
|
echo >&2 'Warning: "fn" command appears to already exist.'
|
||||||
echo >&2 'If you are just upgrading your functions cli client, ignore this and wait a few seconds.'
|
echo >&2 'If you are just upgrading your functions cli client, ignore this and wait a few seconds.'
|
||||||
echo >&2 'You may press Ctrl+C now to abort this process.'
|
echo >&2 'You may press Ctrl+C now to abort this process.'
|
||||||
( set -x; sleep 5 )
|
( set -x; sleep 5 )
|
||||||
@@ -59,21 +59,21 @@ url='https://github.com/iron-io/functions/releases/download'
|
|||||||
# perform some very rudimentary platform detection
|
# perform some very rudimentary platform detection
|
||||||
case "$(uname)" in
|
case "$(uname)" in
|
||||||
Linux)
|
Linux)
|
||||||
$sh_c "$curl /usr/local/bin/fnctl $url/$release/fnctl_linux"
|
$sh_c "$curl /usr/local/bin/fn $url/$release/fn_linux"
|
||||||
$sh_c "chmod +x /usr/local/bin/fnctl"
|
$sh_c "chmod +x /usr/local/bin/fn"
|
||||||
fnctl --version
|
fn --version
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
Darwin)
|
Darwin)
|
||||||
$sh_c "$curl /usr/local/bin/fnctl $url/$release/fnctl_mac"
|
$sh_c "$curl /usr/local/bin/fn $url/$release/fn_mac"
|
||||||
$sh_c "chmod +x /usr/local/bin/fnctl"
|
$sh_c "chmod +x /usr/local/bin/fn"
|
||||||
fnctl --version
|
fn --version
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
WindowsNT)
|
WindowsNT)
|
||||||
$sh_c "$curl $url/$release/fnctl.exe"
|
$sh_c "$curl $url/$release/fn.exe"
|
||||||
# TODO how to make executable? chmod?
|
# TODO how to make executable? chmod?
|
||||||
fnctl.exe --version
|
fn.exe --version
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -81,7 +81,7 @@ esac
|
|||||||
cat >&2 <<'EOF'
|
cat >&2 <<'EOF'
|
||||||
|
|
||||||
Either your platform is not easily detectable or is not supported by this
|
Either your platform is not easily detectable or is not supported by this
|
||||||
installer script (yet - PRs welcome! [fnctl/install]).
|
installer script (yet - PRs welcome! [fn/install]).
|
||||||
Please visit the following URL for more detailed installation instructions:
|
Please visit the following URL for more detailed installation instructions:
|
||||||
|
|
||||||
https://github.com/iron-io/functions
|
https://github.com/iron-io/functions
|
||||||
@@ -37,7 +37,7 @@ func lambda() cli.Command {
|
|||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "lambda",
|
Name: "lambda",
|
||||||
Usage: "create and publish lambda functions",
|
Usage: "create and publish lambda functions",
|
||||||
ArgsUsage: "fnctl lambda",
|
ArgsUsage: "fn lambda",
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
{
|
{
|
||||||
Name: "create-function",
|
Name: "create-function",
|
||||||
@@ -11,11 +11,11 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "fnctl"
|
app.Name = "fn"
|
||||||
app.Version = "0.1.0"
|
app.Version = "0.1.0"
|
||||||
app.Authors = []cli.Author{{Name: "iron.io"}}
|
app.Authors = []cli.Author{{Name: "iron.io"}}
|
||||||
app.Usage = "IronFunctions command line tools"
|
app.Usage = "IronFunctions command line tools"
|
||||||
app.UsageText = `Check the manual at https://github.com/iron-io/functions/blob/master/fnctl/README.md
|
app.UsageText = `Check the manual at https://github.com/iron-io/functions/blob/master/fn/README.md
|
||||||
|
|
||||||
ENVIRONMENT VARIABLES:
|
ENVIRONMENT VARIABLES:
|
||||||
API_URL - IronFunctions remote API address`
|
API_URL - IronFunctions remote API address`
|
||||||
@@ -27,7 +27,7 @@ func routes() cli.Command {
|
|||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "routes",
|
Name: "routes",
|
||||||
Usage: "list routes",
|
Usage: "list routes",
|
||||||
ArgsUsage: "fnctl routes",
|
ArgsUsage: "fn routes",
|
||||||
Action: r.list,
|
Action: r.list,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
{
|
{
|
||||||
@@ -75,7 +75,7 @@ func (r *runCmd) run(c *cli.Context) error {
|
|||||||
// If something is piped in, it works fine.
|
// If something is piped in, it works fine.
|
||||||
// Turns out, this works just fine in our case as the piped stuff works properly and the non-piped doesn't hang either.
|
// Turns out, this works just fine in our case as the piped stuff works properly and the non-piped doesn't hang either.
|
||||||
// See: https://github.com/golang/go/issues/14853#issuecomment-260170423
|
// See: https://github.com/golang/go/issues/14853#issuecomment-260170423
|
||||||
// log.Println("Warning: couldn't stat stdin, you are probably on Windows. Be sure to pipe something into this command, eg: 'echo \"hello\" | fnctl run'")
|
// log.Println("Warning: couldn't stat stdin, you are probably on Windows. Be sure to pipe something into this command, eg: 'echo \"hello\" | fn run'")
|
||||||
} else {
|
} else {
|
||||||
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
||||||
// log.Println("data is being piped to stdin")
|
// log.Println("data is being piped to stdin")
|
||||||
3
fnctl/.gitignore
vendored
3
fnctl/.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
fnctl
|
|
||||||
vendor/
|
|
||||||
/fnctl.exe
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
all: vendor
|
|
||||||
go build -o fnctl
|
|
||||||
./fnctl
|
|
||||||
|
|
||||||
docker: vendor
|
|
||||||
GOOS=linux go build -o fnctl
|
|
||||||
docker build -t iron/fnctl .
|
|
||||||
docker push iron/fnctl
|
|
||||||
|
|
||||||
vendor:
|
|
||||||
glide install -v
|
|
||||||
|
|
||||||
test:
|
|
||||||
go test -v $(shell glide nv)
|
|
||||||
|
|
||||||
release: docker
|
|
||||||
GOOS=linux go build -o fnctl_linux
|
|
||||||
GOOS=darwin go build -o fnctl_mac
|
|
||||||
GOOS=windows go build -o fnctl.exe
|
|
||||||
Reference in New Issue
Block a user