mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fnctl: expand fnctl README.md with new options for configuration (#242)
* fnctl: expand fnctl README.md with new options for configuration * fnctl: extends function files to update routes configurations
This commit is contained in:
committed by
Seif Lotfy سيف لطفي
parent
1ec5aca19e
commit
c985a17b02
@@ -6,7 +6,7 @@ swagger: '2.0'
|
||||
info:
|
||||
title: IronFunctions
|
||||
description:
|
||||
version: "0.0.12"
|
||||
version: "0.0.13"
|
||||
# the domain of the service
|
||||
host: "127.0.0.1:8080"
|
||||
# array of all schemes that your API supports
|
||||
@@ -319,6 +319,10 @@ definitions:
|
||||
required:
|
||||
- route
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
error:
|
||||
$ref: '#/definitions/ErrorBody'
|
||||
route:
|
||||
$ref: '#/definitions/Route'
|
||||
|
||||
|
||||
@@ -96,11 +96,32 @@ and `other`), each subdirectory of these firsts are considered part of the route
|
||||
which instructs `fnctl` 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.
|
||||
|
||||
```
|
||||
$ cat functions.yaml
|
||||
## Functions files (functions.yaml)
|
||||
|
||||
Functions files are used to assist fnctl to execute bulk updates of your
|
||||
functions. The files can be named as:
|
||||
|
||||
- functions.yaml
|
||||
- functions.yml
|
||||
- function.yaml
|
||||
- function.yml
|
||||
- functions.json
|
||||
- function.json
|
||||
- fn.yaml
|
||||
- fn.yml
|
||||
- fn.json
|
||||
|
||||
An example of a function file:
|
||||
```yaml
|
||||
app: myapp
|
||||
image: iron/hello
|
||||
route: "/custom/route"
|
||||
type: sync
|
||||
memory: 128
|
||||
config:
|
||||
key: value
|
||||
key2: value2
|
||||
keyN: valueN
|
||||
build:
|
||||
- make
|
||||
- make test
|
||||
@@ -115,6 +136,19 @@ route updated to use it.
|
||||
`route` (optional) allows you to overwrite the calculated route from the path
|
||||
position. You may use it to override the calculated route.
|
||||
|
||||
`type` (optional) allows you to set the type of the route. `sync`, for functions
|
||||
whose response are sent back to the requester; or `async`, for functions that
|
||||
are started and return a task ID to customer while it executes in background.
|
||||
Default: `sync`.
|
||||
|
||||
`memory` (optional) allows you to set a maximum memory threshold for this
|
||||
function. If this function exceeds this limit during execution, it is stopped
|
||||
and error message is logged. Default: `128`.
|
||||
|
||||
`config` (optional) is a set of configurations to be passed onto the route
|
||||
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
|
||||
`docker push`.
|
||||
|
||||
@@ -34,10 +34,13 @@ var (
|
||||
)
|
||||
|
||||
type funcfile struct {
|
||||
App *string
|
||||
Image string
|
||||
Route *string
|
||||
Build []string
|
||||
App *string
|
||||
Image string
|
||||
Route *string
|
||||
Type string
|
||||
Memory int64
|
||||
Config map[string]string
|
||||
Build []string
|
||||
}
|
||||
|
||||
func parsefuncfile(path string) (*funcfile, error) {
|
||||
|
||||
6
fnctl/glide.lock
generated
6
fnctl/glide.lock
generated
@@ -1,5 +1,5 @@
|
||||
hash: aed45d068e76dc473f16657f44281db6f793e4724e7305b4a6cef45a132da29f
|
||||
updated: 2016-11-07T23:22:33.135398009+01:00
|
||||
hash: ed621664a6ddc808b65620c5be9966978530b06cb1e452ba8db0a5655cbb19d2
|
||||
updated: 2016-11-09T00:20:54.36270079+01:00
|
||||
imports:
|
||||
- name: github.com/aws/aws-sdk-go
|
||||
version: 90dec2183a5f5458ee79cbaf4b8e9ab910bc81a6
|
||||
@@ -77,7 +77,7 @@ imports:
|
||||
- name: github.com/hashicorp/go-cleanhttp
|
||||
version: ad28ea4487f05916463e2423a55166280e8254b5
|
||||
- name: github.com/iron-io/functions_go
|
||||
version: ec65bad1ceb32b29f106483ecdd3e7588b5fde30
|
||||
version: 2942fd282d03cc17dc9663c95b9ee3f6c513db43
|
||||
- name: github.com/iron-io/iron_go3
|
||||
version: b50ecf8ff90187fc5fabccd9d028dd461adce4ee
|
||||
subpackages:
|
||||
|
||||
@@ -8,7 +8,7 @@ import:
|
||||
- bump
|
||||
- storage
|
||||
- package: github.com/iron-io/functions_go
|
||||
version: ec65bad1ceb32b29f106483ecdd3e7588b5fde30
|
||||
version: 2942fd282d03cc17dc9663c95b9ee3f6c513db43
|
||||
- package: github.com/iron-io/iron_go3
|
||||
subpackages:
|
||||
- config
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -107,17 +108,23 @@ func (p *publishcmd) route(path string, ff *funcfile) error {
|
||||
|
||||
body := functions.RouteWrapper{
|
||||
Route: functions.Route{
|
||||
Path: *ff.Route,
|
||||
Image: ff.Image,
|
||||
Path: *ff.Route,
|
||||
Image: ff.Image,
|
||||
Memory: ff.Memory,
|
||||
Type_: ff.Type,
|
||||
Config: ff.Config,
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Fprintf(p.verbwriter, "updating API with appName: %s route: %s image: %s \n", *ff.App, *ff.Route, ff.Image)
|
||||
|
||||
_, _, err := p.AppsAppRoutesPost(*ff.App, body)
|
||||
wrapper, resp, err := p.AppsAppRoutesPost(*ff.App, body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting routes: %v", err)
|
||||
}
|
||||
if resp.StatusCode == http.StatusBadRequest {
|
||||
return fmt.Errorf("error storing this route: %s", wrapper.Error_.Message)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user