mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
api,fn: entrypoint to return daemon version (#367)
This commit is contained in:
committed by
Seif Lotfy سيف لطفي
parent
8cddfdb125
commit
688ffcf39f
44
fn/version.go
Normal file
44
fn/version.go
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user