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 .
|
||||
|
||||
test:
|
||||
go test -v $(shell go list ./... | grep -v vendor | grep -v examples | grep -v tool | grep -v fnctl)
|
||||
cd fnctl && $(MAKE) test
|
||||
go test -v $(shell go list ./... | grep -v vendor | grep -v examples | grep -v tool | grep -v fn)
|
||||
cd fn && $(MAKE) test
|
||||
|
||||
test-datastore:
|
||||
cd api/datastore && go test -v
|
||||
@@ -25,7 +25,7 @@ test-docker:
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v $(DIR):/go/src/github.com/iron-io/functions \
|
||||
-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:
|
||||
./functions
|
||||
|
||||
24
README.md
24
README.md
@@ -87,7 +87,7 @@ configuration options [here](docs/options.md). If you are on Windows, check [her
|
||||
Install the IronFunctions CLI tool:
|
||||
|
||||
```sh
|
||||
curl -sSL http://get.iron.io/fnctl | sh
|
||||
curl -sSL http://get.iron.io/fn | sh
|
||||
```
|
||||
|
||||
### Write a Function
|
||||
@@ -122,17 +122,17 @@ and deploy it.
|
||||
|
||||
```sh
|
||||
# create func.yaml file, replace $USERNAME with your Docker Hub username.
|
||||
fnctl init $USERNAME/hello
|
||||
fn init $USERNAME/hello
|
||||
# build the function
|
||||
fnctl build
|
||||
fn build
|
||||
# test it
|
||||
fnctl run
|
||||
fn run
|
||||
# push it to Docker Hub
|
||||
fnctl push
|
||||
fn push
|
||||
# create an app
|
||||
fnctl apps create myapp
|
||||
fn apps create myapp
|
||||
# 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:
|
||||
@@ -155,7 +155,7 @@ This is a more detailed explanation of the main commands you'll use in IronFunct
|
||||
An application is essentially a grouping of functions, that put together, form an API. Here's how to create an app.
|
||||
|
||||
```sh
|
||||
fnctl apps create myapp
|
||||
fn apps create myapp
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
```sh
|
||||
fnctl routes create myapp /hello iron/hello
|
||||
fn routes create myapp /hello iron/hello
|
||||
```
|
||||
|
||||
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
|
||||
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
|
||||
fnctl call myapp /hello
|
||||
fn call myapp /hello
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```sh
|
||||
echo '{"name":"Johnny"}' | fnctl call myapp /hello
|
||||
echo '{"name":"Johnny"}' | fn call myapp /hello
|
||||
```
|
||||
|
||||
Or using cURL:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
If you are a developer using IronFunctions through the API, this section is for you.
|
||||
|
||||
* [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 Lambda functions](lambda/create.md)
|
||||
* [Function file (func.yaml)](function-file.md)
|
||||
|
||||
@@ -12,7 +12,7 @@ environment variables.
|
||||
Note: Route level configuration overrides app level configuration.
|
||||
|
||||
```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:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 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:
|
||||
|
||||
@@ -49,5 +49,5 @@ setup. These configuration options shall override application configuration
|
||||
during functions execution.
|
||||
|
||||
`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`.
|
||||
@@ -25,7 +25,7 @@ write a simple function and have an "executable" ready to go.
|
||||
## How does it work?
|
||||
|
||||
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
|
||||
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
|
||||
@@ -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
|
||||
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.
|
||||
|
||||
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_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
|
||||
|
||||
```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.
|
||||
|
||||
@@ -4,7 +4,7 @@ Docker images created by running the `create-function` subcommand on a Lambda fu
|
||||
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:
|
||||
```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>`
|
||||
@@ -17,6 +17,6 @@ fnctl lambda create-function <name> <runtime> <handler> <files...>
|
||||
|
||||
e.g:
|
||||
```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.
|
||||
|
||||
We need the the `fnctl` tool for the rest of this guide. You can install it
|
||||
by following [these instructions](https://github.com/iron-io/function/fnctl).
|
||||
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/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.*
|
||||
|
||||
@@ -23,11 +23,11 @@ def my_handler(event, context):
|
||||
Create an empty directory for your project and save this code in a file called
|
||||
`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.
|
||||
|
||||
```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 Dockerfile: irontest/hello_world:1/Dockerfile ... OK
|
||||
Copying file: irontest/hello_world/hello_world:1.py ... OK
|
||||
@@ -40,13 +40,13 @@ 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
|
||||
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
|
||||
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
|
||||
|
||||
Next we want to publish the function to our IronFunctions
|
||||
```sh
|
||||
$ fnctl publish -v -f -d ./irontest
|
||||
$ fn publish -v -f -d ./irontest
|
||||
publishing irontest/hello_world:1/function.yaml
|
||||
Sending build context to Docker daemon 4.096 kB
|
||||
Step 1 : FROM iron/lambda-python2.7
|
||||
@@ -100,7 +100,7 @@ The `test-function` subcommand can launch the Dockerized function with the
|
||||
right parameters.
|
||||
|
||||
```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!"}
|
||||
```
|
||||
|
||||
@@ -108,10 +108,10 @@ You should see the output.
|
||||
|
||||
## 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
|
||||
$ 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!"}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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
|
||||
[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:
|
||||
|
||||
```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
|
||||
@@ -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:
|
||||
|
||||
```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.
|
||||
@@ -50,6 +50,6 @@ by passing `--version <version>.`
|
||||
|
||||
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```
|
||||
@@ -11,7 +11,7 @@ docker run
|
||||
|
||||
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
|
||||
|
||||
@@ -7,7 +7,7 @@ Packaging a function has two parts:
|
||||
|
||||
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.
|
||||
|
||||
@@ -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 .
|
||||
```
|
||||
|
||||
Or using [fnctl](../fnctl/README.md):
|
||||
Or using [fn](../fn/README.md):
|
||||
|
||||
```sh
|
||||
fnctl build
|
||||
fn build
|
||||
```
|
||||
|
||||
### Push your image
|
||||
@@ -53,8 +53,8 @@ This part is simple:
|
||||
docker push $USERNAME/myfunction
|
||||
```
|
||||
|
||||
Or using [fnctl](../fnctl/README.md):
|
||||
Or using [fn](../fn/README.md):
|
||||
|
||||
```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
|
||||
# create your func.yaml file
|
||||
fnctl init <YOUR_DOCKERHUB_USERNAME>/hello
|
||||
fn init <YOUR_DOCKERHUB_USERNAME>/hello
|
||||
# build the function
|
||||
fnctl build
|
||||
fn build
|
||||
# test it
|
||||
cat hello.payload.json | fnctl run
|
||||
cat hello.payload.json | fn run
|
||||
# push it to Docker Hub
|
||||
fnctl push
|
||||
fn push
|
||||
# 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:
|
||||
|
||||
@@ -4,15 +4,15 @@ This example will show you how to test and deploy a Node function to IronFunctio
|
||||
|
||||
```sh
|
||||
# create your func.yaml file
|
||||
fnctl init <YOUR_DOCKERHUB_USERNAME>/hello
|
||||
fn init <YOUR_DOCKERHUB_USERNAME>/hello
|
||||
# build the function
|
||||
fnctl build
|
||||
fn build
|
||||
# test it
|
||||
cat hello.payload.json | fnctl run
|
||||
cat hello.payload.json | fn run
|
||||
# push it to Docker Hub for use with IronFunctions
|
||||
fnctl push
|
||||
fn push
|
||||
# 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
|
||||
|
||||
@@ -21,7 +21,7 @@ the moment you try to test this function.
|
||||
### 2. Build:
|
||||
|
||||
```sh
|
||||
fnctl publish
|
||||
fn publish
|
||||
```
|
||||
|
||||
`-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.
|
||||
|
||||
```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:
|
||||
|
||||
@@ -22,7 +22,7 @@ the moment you try to test this function.
|
||||
### 2. Build:
|
||||
|
||||
```sh
|
||||
fnctl publish
|
||||
fn publish
|
||||
```
|
||||
|
||||
`-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.
|
||||
|
||||
```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:
|
||||
|
||||
@@ -4,17 +4,17 @@ This example will show you how to test and deploy a Ruby function to IronFunctio
|
||||
|
||||
```sh
|
||||
# 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
|
||||
docker run --rm -v "$PWD":/worker -w /worker iron/ruby:dev bundle install --standalone --clean
|
||||
# build the function
|
||||
fnctl build
|
||||
fn build
|
||||
# test it
|
||||
cat hello.payload.json | fnctl run
|
||||
cat hello.payload.json | fn run
|
||||
# push it to Docker Hub for use with IronFunctions
|
||||
fnctl push
|
||||
fn push
|
||||
# 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
|
||||
|
||||
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/*
|
||||
|
||||
COPY entrypoint.sh /
|
||||
COPY fnctl /
|
||||
COPY fn /
|
||||
RUN chmod +x /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:
|
||||
|
||||
```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:
|
||||
|
||||
```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.
|
||||
|
||||
### 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.
|
||||
|
||||
```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.
|
||||
|
||||
```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:
|
||||
|
||||
```sh
|
||||
cat `payload.json` | fnctl run
|
||||
cat `payload.json` | fn run
|
||||
```
|
||||
|
||||
Push will push the function image to Docker Hub.
|
||||
|
||||
```sh
|
||||
fnctl push
|
||||
fn push
|
||||
```
|
||||
|
||||
## Using the API
|
||||
@@ -56,28 +56,28 @@ fnctl push
|
||||
You can operate IronFunctions from the command line.
|
||||
|
||||
```sh
|
||||
$ fnctl apps # list apps
|
||||
$ fn apps # list apps
|
||||
myapp
|
||||
|
||||
$ fnctl apps create otherapp # create new app
|
||||
$ fn apps create otherapp # create new app
|
||||
otherapp created
|
||||
|
||||
$ fnctl apps describe otherapp # describe an app
|
||||
$ fn apps describe otherapp # describe an app
|
||||
app: otherapp
|
||||
no specific configuration
|
||||
|
||||
$ fnctl apps
|
||||
$ fn apps
|
||||
myapp
|
||||
otherapp
|
||||
|
||||
$ fnctl routes myapp # list routes of an app
|
||||
$ fn routes myapp # list routes of an app
|
||||
path image
|
||||
/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
|
||||
|
||||
$ fnctl routes delete otherapp hello # delete route
|
||||
$ fn routes delete otherapp hello # delete route
|
||||
/hello deleted
|
||||
```
|
||||
|
||||
@@ -88,13 +88,13 @@ routes' with an appropriate flag, `config`.
|
||||
|
||||
Thus a more complete example of an application creation will look like:
|
||||
```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
|
||||
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
|
||||
if necessary.
|
||||
|
||||
@@ -105,7 +105,7 @@ choices are: `memory`, `type` and `config`.
|
||||
|
||||
Thus a more complete example of route creation will look like:
|
||||
```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
|
||||
@@ -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
|
||||
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
|
||||
if necessary.
|
||||
|
||||
## 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
|
||||
environment variable (`$API_URL`):
|
||||
```sh
|
||||
$ export API_URL="http://myfunctions.example.org/"
|
||||
$ fnctl ...
|
||||
$ fn ...
|
||||
```
|
||||
|
||||
## Publish
|
||||
@@ -139,7 +139,7 @@ functions, rebuild them and push them to Docker Hub and update them in
|
||||
IronFunction.
|
||||
|
||||
```sh
|
||||
$ fnctl publish
|
||||
$ fn publish
|
||||
path result
|
||||
/app/hello done
|
||||
/app/hello-sync error: no Dockerfile found for this function
|
||||
@@ -173,7 +173,7 @@ following this convention:
|
||||
It will render this pattern of updates:
|
||||
|
||||
```sh
|
||||
$ fnctl publish
|
||||
$ fn publish
|
||||
path result
|
||||
/myapp/route1/subroute1 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
|
||||
(e.g. `route1/subroute1`).
|
||||
|
||||
`fnctl publish` expects that each directory to contain a file `func.yaml`
|
||||
which instructs `fnctl` on how to act with that particular update, and a
|
||||
`fn publish` expects that each directory to contain a file `func.yaml`
|
||||
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.
|
||||
|
||||
## Contributing
|
||||
@@ -196,9 +196,9 @@ done, run:
|
||||
$ 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:
|
||||
|
||||
```sh
|
||||
$ ./fnctl
|
||||
$ ./fn
|
||||
```
|
||||
@@ -21,7 +21,7 @@ func apps() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "apps",
|
||||
Usage: "list apps",
|
||||
ArgsUsage: "fnctl apps",
|
||||
ArgsUsage: "fn apps",
|
||||
Action: a.list,
|
||||
Subcommands: []cli.Command{
|
||||
{
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/iron-io/functions/fnctl/langs"
|
||||
"github.com/iron-io/functions/fn/langs"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -4,4 +4,4 @@ HOST=$(/sbin/ip route|awk '/default/ { print $3 }')
|
||||
|
||||
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:
|
||||
- package: github.com/docker/docker
|
||||
subpackages:
|
||||
@@ -1,7 +1,7 @@
|
||||
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
|
||||
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"
|
||||
|
||||
"github.com/iron-io/functions/fnctl/langs"
|
||||
"github.com/iron-io/functions/fn/langs"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Install script to install fnctl
|
||||
# Install script to install fn
|
||||
|
||||
release='0.1.2'
|
||||
release='0.1.15'
|
||||
|
||||
command_exists() {
|
||||
command -v "$@" > /dev/null 2>&1
|
||||
@@ -19,8 +19,8 @@ case "$(uname -m)" in
|
||||
;;
|
||||
esac
|
||||
|
||||
if command_exists fnctl ; then
|
||||
echo >&2 'Warning: "fnctl" command appears to already exist.'
|
||||
if command_exists fn ; then
|
||||
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 'You may press Ctrl+C now to abort this process.'
|
||||
( set -x; sleep 5 )
|
||||
@@ -59,21 +59,21 @@ url='https://github.com/iron-io/functions/releases/download'
|
||||
# perform some very rudimentary platform detection
|
||||
case "$(uname)" in
|
||||
Linux)
|
||||
$sh_c "$curl /usr/local/bin/fnctl $url/$release/fnctl_linux"
|
||||
$sh_c "chmod +x /usr/local/bin/fnctl"
|
||||
fnctl --version
|
||||
$sh_c "$curl /usr/local/bin/fn $url/$release/fn_linux"
|
||||
$sh_c "chmod +x /usr/local/bin/fn"
|
||||
fn --version
|
||||
exit 0
|
||||
;;
|
||||
Darwin)
|
||||
$sh_c "$curl /usr/local/bin/fnctl $url/$release/fnctl_mac"
|
||||
$sh_c "chmod +x /usr/local/bin/fnctl"
|
||||
fnctl --version
|
||||
$sh_c "$curl /usr/local/bin/fn $url/$release/fn_mac"
|
||||
$sh_c "chmod +x /usr/local/bin/fn"
|
||||
fn --version
|
||||
exit 0
|
||||
;;
|
||||
WindowsNT)
|
||||
$sh_c "$curl $url/$release/fnctl.exe"
|
||||
$sh_c "$curl $url/$release/fn.exe"
|
||||
# TODO how to make executable? chmod?
|
||||
fnctl.exe --version
|
||||
fn.exe --version
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
@@ -81,7 +81,7 @@ esac
|
||||
cat >&2 <<'EOF'
|
||||
|
||||
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:
|
||||
|
||||
https://github.com/iron-io/functions
|
||||
@@ -37,7 +37,7 @@ func lambda() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "lambda",
|
||||
Usage: "create and publish lambda functions",
|
||||
ArgsUsage: "fnctl lambda",
|
||||
ArgsUsage: "fn lambda",
|
||||
Subcommands: []cli.Command{
|
||||
{
|
||||
Name: "create-function",
|
||||
@@ -11,11 +11,11 @@ import (
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "fnctl"
|
||||
app.Name = "fn"
|
||||
app.Version = "0.1.0"
|
||||
app.Authors = []cli.Author{{Name: "iron.io"}}
|
||||
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:
|
||||
API_URL - IronFunctions remote API address`
|
||||
@@ -27,7 +27,7 @@ func routes() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "routes",
|
||||
Usage: "list routes",
|
||||
ArgsUsage: "fnctl routes",
|
||||
ArgsUsage: "fn routes",
|
||||
Action: r.list,
|
||||
Subcommands: []cli.Command{
|
||||
{
|
||||
@@ -75,7 +75,7 @@ func (r *runCmd) run(c *cli.Context) error {
|
||||
// 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.
|
||||
// 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 {
|
||||
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
||||
// 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