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
|
||||
```
|
||||
|
||||
## 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
|
||||
|
||||
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",
|
||||
Usage: "list apps",
|
||||
ArgsUsage: "fnctl apps",
|
||||
Flags: append(confFlags(&a.Configuration), []cli.Flag{}...),
|
||||
Action: a.list,
|
||||
Subcommands: []cli.Command{
|
||||
{
|
||||
|
||||
@@ -15,7 +15,10 @@ func main() {
|
||||
app.Version = "0.0.1"
|
||||
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/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.Commands = []cli.Command{
|
||||
apps(),
|
||||
@@ -32,7 +35,12 @@ func main() {
|
||||
}
|
||||
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
@@ -41,15 +49,3 @@ func resetBasePath(c *functions.Configuration) error {
|
||||
|
||||
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
|
||||
flags = append(flags, cmd.flags()...)
|
||||
flags = append(flags, cmd.commoncmd.flags()...)
|
||||
flags = append(flags, confFlags(&cmd.Configuration)...)
|
||||
return cli.Command{
|
||||
Name: "publish",
|
||||
Usage: "scan local directory for functions, build and publish them.",
|
||||
|
||||
@@ -18,7 +18,6 @@ func push() cli.Command {
|
||||
}
|
||||
var flags []cli.Flag
|
||||
flags = append(flags, cmd.commoncmd.flags()...)
|
||||
flags = append(flags, confFlags(&cmd.Configuration)...)
|
||||
return cli.Command{
|
||||
Name: "push",
|
||||
Usage: "scan local directory for functions and push them.",
|
||||
|
||||
@@ -23,12 +23,10 @@ type routesCmd struct {
|
||||
func routes() cli.Command {
|
||||
r := routesCmd{RoutesApi: functions.NewRoutesApi()}
|
||||
|
||||
flags := append(confFlags(&r.Configuration), []cli.Flag{}...)
|
||||
return cli.Command{
|
||||
Name: "routes",
|
||||
Usage: "list routes",
|
||||
ArgsUsage: "fnctl routes",
|
||||
Flags: flags,
|
||||
Action: r.list,
|
||||
Subcommands: []cli.Command{
|
||||
{
|
||||
@@ -36,7 +34,7 @@ func routes() cli.Command {
|
||||
Usage: "call a route",
|
||||
ArgsUsage: "appName /path",
|
||||
Action: r.call,
|
||||
Flags: append(flags, runflags()...),
|
||||
Flags: runflags(),
|
||||
},
|
||||
{
|
||||
Name: "create",
|
||||
@@ -73,13 +71,11 @@ func routes() cli.Command {
|
||||
func call() cli.Command {
|
||||
r := routesCmd{RoutesApi: functions.NewRoutesApi()}
|
||||
|
||||
flags := append([]cli.Flag{}, confFlags(&r.Configuration)...)
|
||||
flags = append(flags, runflags()...)
|
||||
return cli.Command{
|
||||
Name: "call",
|
||||
Usage: "call a remote function",
|
||||
ArgsUsage: "appName /path",
|
||||
Flags: flags,
|
||||
Flags: runflags(),
|
||||
Action: r.call,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user