mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fnctl: improve help on how to configure remote server (#246)
* fnctl: improve help on how to configure remote server Partially addresses #241 * fnctl: HOST/FNCTL_HOST -> API_URL * fnctl: improve help on how to configure remote server
This commit is contained in:
@@ -45,6 +45,16 @@ $ fnctl routes delete otherapp hello # delete route
|
|||||||
/hello deleted
|
/hello deleted
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Changing target host
|
||||||
|
|
||||||
|
`fnctl` is configured by default to talk to a locally installed IronFunctions.
|
||||||
|
You may reconfigure it to talk to a remote installation by updating a local
|
||||||
|
environment variable (`$API_URL`):
|
||||||
|
```sh
|
||||||
|
$ export API_URL="http://myfunctions.example.org/"
|
||||||
|
$ fnctl ...
|
||||||
|
```
|
||||||
|
|
||||||
## Publish
|
## Publish
|
||||||
|
|
||||||
Also there is the publish command that is going to scan all local directory for
|
Also there is the publish command that is going to scan all local directory for
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ func apps() cli.Command {
|
|||||||
Name: "apps",
|
Name: "apps",
|
||||||
Usage: "list apps",
|
Usage: "list apps",
|
||||||
ArgsUsage: "fnctl apps",
|
ArgsUsage: "fnctl apps",
|
||||||
Flags: append(confFlags(&a.Configuration), []cli.Flag{}...),
|
|
||||||
Action: a.list,
|
Action: a.list,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ func main() {
|
|||||||
app.Version = "0.0.1"
|
app.Version = "0.0.1"
|
||||||
app.Authors = []cli.Author{{Name: "iron.io"}}
|
app.Authors = []cli.Author{{Name: "iron.io"}}
|
||||||
app.Usage = "IronFunctions command line tools"
|
app.Usage = "IronFunctions command line tools"
|
||||||
app.UsageText = "Check the manual at https://github.com/iron-io/functions/blob/master/fnctl/README.md"
|
app.UsageText = `Check the manual at https://github.com/iron-io/functions/blob/master/fnctl/README.md
|
||||||
|
|
||||||
|
ENVIRONMENT VARIABLES:
|
||||||
|
API_URL - IronFunctions remote API address`
|
||||||
app.CommandNotFound = func(c *cli.Context, cmd string) { fmt.Fprintf(os.Stderr, "command not found: %v\n", cmd) }
|
app.CommandNotFound = func(c *cli.Context, cmd string) { fmt.Fprintf(os.Stderr, "command not found: %v\n", cmd) }
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
apps(),
|
apps(),
|
||||||
@@ -32,7 +35,12 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resetBasePath(c *functions.Configuration) error {
|
func resetBasePath(c *functions.Configuration) error {
|
||||||
u, err := url.Parse(c.Host)
|
apiURL := os.Getenv("API_URL")
|
||||||
|
if apiURL == "" {
|
||||||
|
apiURL = "http://localhost:8080/"
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err := url.Parse(apiURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -41,15 +49,3 @@ func resetBasePath(c *functions.Configuration) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func confFlags(c *functions.Configuration) []cli.Flag {
|
|
||||||
return []cli.Flag{
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "endpoint",
|
|
||||||
Usage: "url to functions api endpoint e.g. http://functions.iron.io",
|
|
||||||
Destination: &c.Host,
|
|
||||||
EnvVar: "HOST",
|
|
||||||
Value: "http://localhost:8080",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ func publish() cli.Command {
|
|||||||
var flags []cli.Flag
|
var flags []cli.Flag
|
||||||
flags = append(flags, cmd.flags()...)
|
flags = append(flags, cmd.flags()...)
|
||||||
flags = append(flags, cmd.commoncmd.flags()...)
|
flags = append(flags, cmd.commoncmd.flags()...)
|
||||||
flags = append(flags, confFlags(&cmd.Configuration)...)
|
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "publish",
|
Name: "publish",
|
||||||
Usage: "scan local directory for functions, build and publish them.",
|
Usage: "scan local directory for functions, build and publish them.",
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ func push() cli.Command {
|
|||||||
}
|
}
|
||||||
var flags []cli.Flag
|
var flags []cli.Flag
|
||||||
flags = append(flags, cmd.commoncmd.flags()...)
|
flags = append(flags, cmd.commoncmd.flags()...)
|
||||||
flags = append(flags, confFlags(&cmd.Configuration)...)
|
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "push",
|
Name: "push",
|
||||||
Usage: "scan local directory for functions and push them.",
|
Usage: "scan local directory for functions and push them.",
|
||||||
|
|||||||
@@ -23,12 +23,10 @@ type routesCmd struct {
|
|||||||
func routes() cli.Command {
|
func routes() cli.Command {
|
||||||
r := routesCmd{RoutesApi: functions.NewRoutesApi()}
|
r := routesCmd{RoutesApi: functions.NewRoutesApi()}
|
||||||
|
|
||||||
flags := append(confFlags(&r.Configuration), []cli.Flag{}...)
|
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "routes",
|
Name: "routes",
|
||||||
Usage: "list routes",
|
Usage: "list routes",
|
||||||
ArgsUsage: "fnctl routes",
|
ArgsUsage: "fnctl routes",
|
||||||
Flags: flags,
|
|
||||||
Action: r.list,
|
Action: r.list,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
{
|
{
|
||||||
@@ -36,7 +34,7 @@ func routes() cli.Command {
|
|||||||
Usage: "call a route",
|
Usage: "call a route",
|
||||||
ArgsUsage: "appName /path",
|
ArgsUsage: "appName /path",
|
||||||
Action: r.call,
|
Action: r.call,
|
||||||
Flags: append(flags, runflags()...),
|
Flags: runflags(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "create",
|
Name: "create",
|
||||||
@@ -73,13 +71,11 @@ func routes() cli.Command {
|
|||||||
func call() cli.Command {
|
func call() cli.Command {
|
||||||
r := routesCmd{RoutesApi: functions.NewRoutesApi()}
|
r := routesCmd{RoutesApi: functions.NewRoutesApi()}
|
||||||
|
|
||||||
flags := append([]cli.Flag{}, confFlags(&r.Configuration)...)
|
|
||||||
flags = append(flags, runflags()...)
|
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "call",
|
Name: "call",
|
||||||
Usage: "call a remote function",
|
Usage: "call a remote function",
|
||||||
ArgsUsage: "appName /path",
|
ArgsUsage: "appName /path",
|
||||||
Flags: flags,
|
Flags: runflags(),
|
||||||
Action: r.call,
|
Action: r.call,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user