mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Update fn tool
This commit is contained in:
30
Gopkg.lock
generated
30
Gopkg.lock
generated
@@ -1,4 +1,4 @@
|
||||
memo = "d628d38d5466c7cb518c5958cac84faf570f2082027b3868f7e035b871a2fc6f"
|
||||
memo = "8125a14a7245aa6261731457ebbae9061e1454dc4fdd9e2363225c5fedc67eab"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -51,8 +51,8 @@ memo = "d628d38d5466c7cb518c5958cac84faf570f2082027b3868f7e035b871a2fc6f"
|
||||
[[projects]]
|
||||
name = "github.com/aws/aws-sdk-go"
|
||||
packages = ["aws","aws/awserr","aws/awsutil","aws/client","aws/client/metadata","aws/corehandlers","aws/credentials","aws/credentials/ec2rolecreds","aws/credentials/endpointcreds","aws/credentials/stscreds","aws/defaults","aws/ec2metadata","aws/endpoints","aws/request","aws/session","aws/signer/v4","internal/shareddefaults","private/protocol","private/protocol/json/jsonutil","private/protocol/jsonrpc","private/protocol/query","private/protocol/query/queryutil","private/protocol/rest","private/protocol/restjson","private/protocol/xml/xmlutil","service/lambda","service/sts"]
|
||||
revision = "328d4b6c297ec5d4f86543fca46254699d82cada"
|
||||
version = "v1.8.35"
|
||||
revision = "512bdaf8bec30abd545b440447cebb57b53d3af9"
|
||||
version = "v1.8.36"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/boltdb/bolt"
|
||||
@@ -118,7 +118,7 @@ memo = "d628d38d5466c7cb518c5958cac84faf570f2082027b3868f7e035b871a2fc6f"
|
||||
branch = "master"
|
||||
name = "github.com/docker/cli"
|
||||
packages = ["cli/config/configfile"]
|
||||
revision = "51b00f966e1da76b4a896f0ea89151f5c0d63685"
|
||||
revision = "583ed2e3be35221191802f1f6d4a097816effc07"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/docker/distribution"
|
||||
@@ -165,8 +165,8 @@ memo = "d628d38d5466c7cb518c5958cac84faf570f2082027b3868f7e035b871a2fc6f"
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/funcy/functions_go"
|
||||
packages = [".","client","client/apps","client/routes","client/tasks","client/version","models"]
|
||||
revision = "e995899e0032f175bb111c3ccd9777e16486882c"
|
||||
packages = [".","client","client/apps","client/call","client/routes","client/tasks","client/version","models"]
|
||||
revision = "3b83bbd98c2a5909eea3ccfafe3730a9822d15ee"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/garyburd/redigo"
|
||||
@@ -232,7 +232,7 @@ memo = "d628d38d5466c7cb518c5958cac84faf570f2082027b3868f7e035b871a2fc6f"
|
||||
branch = "master"
|
||||
name = "github.com/go-openapi/spec"
|
||||
packages = ["."]
|
||||
revision = "e51c28f07047ad90caff03f6450908720d337e0c"
|
||||
revision = "e81a13315ac92ce3e73075856c5cd50301695405"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -366,6 +366,12 @@ memo = "d628d38d5466c7cb518c5958cac84faf570f2082027b3868f7e035b871a2fc6f"
|
||||
revision = "fc9e8d8ef48496124e79ae0df75490096eccf6fe"
|
||||
version = "v0.0.2"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/mattn/go-runewidth"
|
||||
packages = ["."]
|
||||
revision = "9e777a8366cce605130a531d2cd6363d07ad7317"
|
||||
version = "v0.0.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/mitchellh/mapstructure"
|
||||
@@ -378,6 +384,12 @@ memo = "d628d38d5466c7cb518c5958cac84faf570f2082027b3868f7e035b871a2fc6f"
|
||||
revision = "092cba3727bb9b4a2f0e922cd6c0f93ea270e363"
|
||||
version = "v1.13.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/olekukonko/tablewriter"
|
||||
packages = ["."]
|
||||
revision = "febf2d34b54a69ce7530036c7503b1c9fbfdf0bb"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/opencontainers/runc"
|
||||
packages = ["libcontainer/system","libcontainer/user"]
|
||||
@@ -460,7 +472,7 @@ memo = "d628d38d5466c7cb518c5958cac84faf570f2082027b3868f7e035b871a2fc6f"
|
||||
branch = "master"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = ["bcrypt","blowfish"]
|
||||
revision = "e1a4589e7d3ea14a3352255d04b6f1a418845e5e"
|
||||
revision = "e7ba82683099cae71475961448ab8f903ea77c26"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -478,7 +490,7 @@ memo = "d628d38d5466c7cb518c5958cac84faf570f2082027b3868f7e035b871a2fc6f"
|
||||
branch = "master"
|
||||
name = "golang.org/x/text"
|
||||
packages = ["internal/gen","internal/triegen","internal/ucd","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable","width"]
|
||||
revision = "ccbd3f7822129ff389f8ca4858a9b9d4d910531c"
|
||||
revision = "ab6d1c143672de99b9dfde433b7f6affb278cc74"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/go-playground/validator.v8"
|
||||
|
||||
@@ -6,7 +6,7 @@ swagger: '2.0'
|
||||
info:
|
||||
title: Oracle Functions
|
||||
description: The open source serverless platform.
|
||||
version: "0.1.30"
|
||||
version: "0.1.32"
|
||||
# the domain of the service
|
||||
host: "127.0.0.1:8080"
|
||||
# array of all schemes that your API supports
|
||||
@@ -424,10 +424,12 @@ definitions:
|
||||
timeout:
|
||||
type: integer
|
||||
default: 30
|
||||
format: int32
|
||||
description: Timeout for executions of this route. Value in Seconds
|
||||
idle_timeout:
|
||||
type: integer
|
||||
default: 30
|
||||
format: int32
|
||||
description: Hot functions idle timeout before termination. Value in Seconds
|
||||
|
||||
App:
|
||||
@@ -499,17 +501,14 @@ definitions:
|
||||
CallsWrapper:
|
||||
type: object
|
||||
required:
|
||||
- app
|
||||
- route
|
||||
- calls
|
||||
properties:
|
||||
app:
|
||||
type: string
|
||||
description: "Name of this app."
|
||||
readOnly: true
|
||||
route:
|
||||
type: string
|
||||
description: "Name of this app."
|
||||
readOnly: true
|
||||
calls:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/Call'
|
||||
error:
|
||||
$ref: '#/definitions/ErrorBody'
|
||||
|
||||
CallWrapper:
|
||||
type: object
|
||||
@@ -517,46 +516,43 @@ definitions:
|
||||
- call
|
||||
properties:
|
||||
call:
|
||||
type: string
|
||||
description: "Call ID."
|
||||
readOnly: true
|
||||
|
||||
$ref: '#/definitions/Call'
|
||||
description: "Call object."
|
||||
|
||||
Call:
|
||||
allOf:
|
||||
- type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Call UUID ID.
|
||||
readOnly: true
|
||||
status:
|
||||
type: string
|
||||
description: Call execution status.
|
||||
readOnly: true
|
||||
app_name:
|
||||
type: string
|
||||
description: App name that is assigned to a route that is being executed.
|
||||
readOnly: true
|
||||
path:
|
||||
type: string
|
||||
description: App route that is being executed.
|
||||
readOnly: true
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time when call was submitted. Always in UTC.
|
||||
readOnly: true
|
||||
started_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time when call started execution. Always in UTC.
|
||||
readOnly: true
|
||||
completed_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time when call completed, whether it was successul or failed. Always in UTC.
|
||||
readOnly: true
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Call UUID ID.
|
||||
readOnly: true
|
||||
status:
|
||||
type: string
|
||||
description: Call execution status.
|
||||
readOnly: true
|
||||
app_name:
|
||||
type: string
|
||||
description: App name that is assigned to a route that is being executed.
|
||||
readOnly: true
|
||||
path:
|
||||
type: string
|
||||
description: App route that is being executed.
|
||||
readOnly: true
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time when call was submitted. Always in UTC.
|
||||
readOnly: true
|
||||
started_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time when call started execution. Always in UTC.
|
||||
readOnly: true
|
||||
completed_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time when call completed, whether it was successul or failed. Always in UTC.
|
||||
readOnly: true
|
||||
|
||||
Task:
|
||||
allOf:
|
||||
|
||||
42
fn/Gopkg.lock
generated
42
fn/Gopkg.lock
generated
@@ -1,5 +1,4 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
memo = "19d3a6585c6e407762e05d092d7cd1558b6e418ee25fa3a18553ffc0006a3d26"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -34,8 +33,8 @@
|
||||
[[projects]]
|
||||
name = "github.com/aws/aws-sdk-go"
|
||||
packages = ["aws","aws/awserr","aws/awsutil","aws/client","aws/client/metadata","aws/corehandlers","aws/credentials","aws/credentials/ec2rolecreds","aws/credentials/endpointcreds","aws/credentials/stscreds","aws/defaults","aws/ec2metadata","aws/endpoints","aws/request","aws/session","aws/signer/v4","internal/shareddefaults","private/protocol","private/protocol/json/jsonutil","private/protocol/jsonrpc","private/protocol/query","private/protocol/query/queryutil","private/protocol/rest","private/protocol/restjson","private/protocol/xml/xmlutil","service/lambda","service/sts"]
|
||||
revision = "f9a14dadf426ac17058f5ed3ec9bac9a61b5990b"
|
||||
version = "v1.8.33"
|
||||
revision = "512bdaf8bec30abd545b440447cebb57b53d3af9"
|
||||
version = "v1.8.36"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/coreos/go-semver"
|
||||
@@ -58,8 +57,8 @@
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/funcy/functions_go"
|
||||
packages = [".","client","client/apps","client/routes","client/tasks","client/version","models"]
|
||||
revision = "6ab40fd04a355106389f52a5a3815b1b771b18c7"
|
||||
packages = [".","client","client/apps","client/call","client/routes","client/tasks","client/version","models"]
|
||||
revision = "3b83bbd98c2a5909eea3ccfafe3730a9822d15ee"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/giantswarm/semver-bump"
|
||||
@@ -70,8 +69,8 @@
|
||||
[[projects]]
|
||||
name = "github.com/go-ini/ini"
|
||||
packages = ["."]
|
||||
revision = "36da989cdc560b989d8f195aec46214d33665d20"
|
||||
version = "v1.27.2"
|
||||
revision = "d3de07a94d22b4a0972deb4b96d790c2c0ce8333"
|
||||
version = "v1.28.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -113,7 +112,7 @@
|
||||
branch = "master"
|
||||
name = "github.com/go-openapi/spec"
|
||||
packages = ["."]
|
||||
revision = "e51c28f07047ad90caff03f6450908720d337e0c"
|
||||
revision = "e81a13315ac92ce3e73075856c5cd50301695405"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -125,7 +124,7 @@
|
||||
branch = "master"
|
||||
name = "github.com/go-openapi/swag"
|
||||
packages = ["."]
|
||||
revision = "e43299b4afa7bc7f22e5e82e3d48607230e4c177"
|
||||
revision = "f3f9494671f93fcff853e3c6e9e948b3eb71e590"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -163,6 +162,12 @@
|
||||
packages = ["buffer","jlexer","jwriter"]
|
||||
revision = "44c0351a5bc860bcb2608d54aa03ea686c4e7b25"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/mattn/go-runewidth"
|
||||
packages = ["."]
|
||||
revision = "9e777a8366cce605130a531d2cd6363d07ad7317"
|
||||
version = "v0.0.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/mitchellh/mapstructure"
|
||||
@@ -175,6 +180,12 @@
|
||||
revision = "092cba3727bb9b4a2f0e922cd6c0f93ea270e363"
|
||||
version = "v1.13.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/olekukonko/tablewriter"
|
||||
packages = ["."]
|
||||
revision = "febf2d34b54a69ce7530036c7503b1c9fbfdf0bb"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/urfave/cli"
|
||||
packages = ["."]
|
||||
@@ -185,7 +196,7 @@
|
||||
branch = "master"
|
||||
name = "golang.org/x/net"
|
||||
packages = ["context","context/ctxhttp","idna","publicsuffix"]
|
||||
revision = "3da985ce5951d99de868be4385f21ea6c2b22f24"
|
||||
revision = "59a0b19b5533c7977ddeb86b017bf507ed407b12"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -197,7 +208,7 @@
|
||||
branch = "master"
|
||||
name = "golang.org/x/text"
|
||||
packages = ["internal/gen","internal/triegen","internal/ucd","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable","width"]
|
||||
revision = "4ee4af566555f5fbe026368b75596286a312663a"
|
||||
revision = "ab6d1c143672de99b9dfde433b7f6affb278cc74"
|
||||
|
||||
[[projects]]
|
||||
branch = "v2"
|
||||
@@ -210,10 +221,3 @@
|
||||
name = "gopkg.in/yaml.v2"
|
||||
packages = ["."]
|
||||
revision = "cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "dd217cf3430519442b9eca700adbe81e4ac9abeed9174f9fd9ae3089f18c332a"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
||||
24
fn/README.md
24
fn/README.md
@@ -82,9 +82,29 @@ $ fn routes delete otherapp hello # delete route
|
||||
$ fn routes headers set otherapp hello header-name value # add HTTP header to response
|
||||
otherapp /hello headers updated header-name with value
|
||||
|
||||
|
||||
$ fn calls list myapp /hello # lists all available calls for /hello route from myapp
|
||||
ID: 45bd486b-6eec-548a-bc1a-94d59deef4ac
|
||||
App: myapp
|
||||
Route: /hello
|
||||
Created At: 2017-06-02T15:23:53.263+03:00
|
||||
Started At: 2017-06-02T15:23:53.263+03:00
|
||||
Completed At: 2017-06-02T15:23:53.532+03:00
|
||||
Status: success
|
||||
|
||||
$ fn calls get 45bd486b-6eec-548a-bc1a-94d59deef4ac # gets specific calls by ID
|
||||
ID: 45bd486b-6eec-548a-bc1a-94d59deef4ac
|
||||
App: myapp
|
||||
Route: /hello
|
||||
Created At: 2017-06-02T15:23:53.263+03:00
|
||||
Started At: 2017-06-02T15:23:53.263+03:00
|
||||
Completed At: 2017-06-02T15:23:53.532+03:00
|
||||
Status: success
|
||||
|
||||
|
||||
$ fn version # shows version both of client and server
|
||||
Client version: 0.1.0
|
||||
Server version: 0.1.21
|
||||
Client version: 0.3.7
|
||||
Server version 0.3.7
|
||||
```
|
||||
|
||||
## Application level configuration
|
||||
|
||||
96
fn/calls.go
Normal file
96
fn/calls.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"context"
|
||||
|
||||
"github.com/funcy/functions_go/models"
|
||||
fnclient "github.com/funcy/functions_go/client"
|
||||
apicall "github.com/funcy/functions_go/client/call"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
type callsCmd struct {
|
||||
client *fnclient.Functions
|
||||
}
|
||||
|
||||
func calls() cli.Command {
|
||||
c := callsCmd{client: apiClient()}
|
||||
|
||||
return cli.Command{
|
||||
Name: "calls",
|
||||
Usage: "manage function calls",
|
||||
Subcommands: []cli.Command{
|
||||
{
|
||||
Name: "get",
|
||||
Aliases: []string{"g"},
|
||||
Usage: "get function call info",
|
||||
ArgsUsage: "<call-id>",
|
||||
Action: c.get,
|
||||
},
|
||||
{
|
||||
Name: "list",
|
||||
Aliases: []string{"l"},
|
||||
Usage: "list all calls for specific route",
|
||||
ArgsUsage: "<app> <route>",
|
||||
Action: c.list,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func printCalls(calls []*models.Call) {
|
||||
for _, call := range calls{
|
||||
fmt.Println(fmt.Sprintf(
|
||||
"ID: %v\n" +
|
||||
"App: %v\n" +
|
||||
"Route: %v\n" +
|
||||
"Created At: %v\n" +
|
||||
"Started At: %v\n" +
|
||||
"Completed At: %v\n" +
|
||||
"Status: %v\n",
|
||||
call.ID, call.AppName, call.Path, call.CreatedAt,
|
||||
call.StartedAt, call.CompletedAt, call.Status))
|
||||
}
|
||||
}
|
||||
|
||||
func (call *callsCmd) get(ctx *cli.Context) error {
|
||||
call_id := ctx.Args().Get(0)
|
||||
params := apicall.GetCallsCallParams{
|
||||
Call: call_id,
|
||||
Context: context.Background(),
|
||||
}
|
||||
resp, err := call.client.Call.GetCallsCall(¶ms)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case *apicall.GetCallsCallNotFound:
|
||||
return fmt.Errorf("error: %v", err.(
|
||||
*apicall.GetCallsCallNotFound).Payload.Error.Message)
|
||||
}
|
||||
return fmt.Errorf("unexpected error: %v", err)
|
||||
|
||||
}
|
||||
printCalls([]*models.Call{resp.Payload.Call})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (call *callsCmd) list(ctx *cli.Context) error {
|
||||
app, route := ctx.Args().Get(0), ctx.Args().Get(1)
|
||||
params := apicall.GetAppsAppCallsRouteParams{
|
||||
App: app,
|
||||
Route: route,
|
||||
Context: context.Background(),
|
||||
}
|
||||
resp, err := call.client.Call.GetAppsAppCallsRoute(¶ms)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case *apicall.GetCallsCallNotFound:
|
||||
return fmt.Errorf("error: %v", err.(
|
||||
*apicall.GetCallsCallNotFound).Payload.Error.Message)
|
||||
}
|
||||
return fmt.Errorf("unexpected error: %v", err)
|
||||
|
||||
}
|
||||
printCalls(resp.Payload.Calls)
|
||||
return nil
|
||||
}
|
||||
14
fn/main.go
14
fn/main.go
@@ -12,12 +12,13 @@ import (
|
||||
)
|
||||
|
||||
var aliases = map[string]cli.Command{
|
||||
"build": build(),
|
||||
"bump": bump(),
|
||||
"deploy": deploy(),
|
||||
"push": push(),
|
||||
"run": run(),
|
||||
"call": call(),
|
||||
"build": build(),
|
||||
"bump": bump(),
|
||||
"deploy": deploy(),
|
||||
"push": push(),
|
||||
"run": run(),
|
||||
"call": call(),
|
||||
"calls": calls(),
|
||||
}
|
||||
|
||||
func aliasesFn() []cli.Command {
|
||||
@@ -77,6 +78,7 @@ GLOBAL OPTIONS:
|
||||
images(),
|
||||
lambda(),
|
||||
version(),
|
||||
calls(),
|
||||
}
|
||||
app.Commands = append(app.Commands, aliasesFn()...)
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ func routeWithFlags(c *cli.Context, rt *fnmodels.Route) {
|
||||
}
|
||||
|
||||
if t := c.Duration("timeout"); t > 0 {
|
||||
to := int64(t.Seconds())
|
||||
to := int32(t.Seconds())
|
||||
rt.Timeout = &to
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ func routeWithFuncFile(c *cli.Context, ff *funcfile, rt *fnmodels.Route) error {
|
||||
rt.Format = *ff.Format
|
||||
}
|
||||
if ff.Timeout != nil {
|
||||
to := int64(ff.Timeout.Seconds())
|
||||
to := int32(ff.Timeout.Seconds())
|
||||
rt.Timeout = &to
|
||||
}
|
||||
if rt.Path == "" && ff.Path != nil {
|
||||
|
||||
Reference in New Issue
Block a user