diff --git a/docs/swagger.yml b/docs/swagger.yml index 28639f521..249e92e20 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -6,7 +6,7 @@ swagger: '2.0' info: title: IronFunctions description: The open source serverless platform. - version: "0.1.20" + version: "0.1.21" # the domain of the service host: "127.0.0.1:8080" # array of all schemes that your API supports @@ -20,6 +20,16 @@ consumes: produces: - application/json paths: + /version: + get: + summary: "Get daemon version." + tags: + - Version + responses: + 200: + description: Daemon version. + schema: + $ref: '#/definitions/Version' /apps: get: summary: "Get all app names." @@ -364,6 +374,13 @@ definitions: additionalProperties: type: string + Version: + type: object + properties: + version: + type: string + readOnly: true + RoutesWrapper: type: object required: diff --git a/fn/README.md b/fn/README.md index a52051014..1adccdcbd 100644 --- a/fn/README.md +++ b/fn/README.md @@ -79,6 +79,10 @@ $ fn routes create otherapp /hello iron/hello # create route $ fn routes delete otherapp hello # delete route /hello deleted + +$ fn version # shows version both of client and server +Client version: 0.1.0 +Server version: 0.1.21 ``` ## Application level configuration diff --git a/fn/main.go b/fn/main.go index 730daf0e7..b83113a90 100644 --- a/fn/main.go +++ b/fn/main.go @@ -9,10 +9,12 @@ import ( "github.com/urfave/cli" ) +const fnversion = "0.1.39" + func main() { app := cli.NewApp() app.Name = "fn" - app.Version = "0.1.0" + app.Version = fnversion 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/fn/README.md @@ -25,12 +27,13 @@ ENVIRONMENT VARIABLES: build(), bump(), call(), + initFn(), lambda(), publish(), push(), routes(), run(), - initFn(), + version(), } app.Run(os.Args) } @@ -38,7 +41,7 @@ ENVIRONMENT VARIABLES: func resetBasePath(c *functions.Configuration) error { apiURL := os.Getenv("API_URL") if apiURL == "" { - apiURL = "http://localhost:8080/" + apiURL = "http://localhost:8080" } u, err := url.Parse(apiURL) diff --git a/fn/version.go b/fn/version.go new file mode 100644 index 000000000..f36e6bb44 --- /dev/null +++ b/fn/version.go @@ -0,0 +1,44 @@ +package main + +import ( + "fmt" + "net/url" + "os" + + functions "github.com/iron-io/functions_go" + "github.com/urfave/cli" +) + +func version() cli.Command { + r := versionCmd{VersionApi: functions.NewVersionApi()} + return cli.Command{ + Name: "version", + Usage: "displays fn and functions daemon versions", + Action: r.version, + } +} + +type versionCmd struct { + *functions.VersionApi +} + +func (r *versionCmd) version(c *cli.Context) error { + apiURL := os.Getenv("API_URL") + if apiURL == "" { + apiURL = "http://localhost:8080" + } + + u, err := url.Parse(apiURL) + if err != nil { + return err + } + r.Configuration.BasePath = u.String() + + fmt.Println("Client version:", fnversion) + v, _, err := r.VersionGet() + if err != nil { + return err + } + fmt.Println("Server version", v.Version) + return nil +}