diff --git a/docs/swagger.yml b/docs/swagger.yml index 0cae74cd7..d267af0b6 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -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' diff --git a/fnctl/README.md b/fnctl/README.md index 0519f183b..7d029c308 100644 --- a/fnctl/README.md +++ b/fnctl/README.md @@ -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`. diff --git a/fnctl/common.go b/fnctl/common.go index 31e80c0ec..471897399 100644 --- a/fnctl/common.go +++ b/fnctl/common.go @@ -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) { diff --git a/fnctl/glide.lock b/fnctl/glide.lock index 435e7c98b..8edb6b3b0 100644 --- a/fnctl/glide.lock +++ b/fnctl/glide.lock @@ -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: diff --git a/fnctl/glide.yaml b/fnctl/glide.yaml index a20c8436f..bf7ec8cac 100644 --- a/fnctl/glide.yaml +++ b/fnctl/glide.yaml @@ -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 diff --git a/fnctl/publish.go b/fnctl/publish.go index 494ee6781..b16af012c 100644 --- a/fnctl/publish.go +++ b/fnctl/publish.go @@ -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 }