mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fnctl: change from host/scheme flag to endpoint flag (#231)
* fnctl: change from host/schem flag to endpoint flag * keep same format
This commit is contained in:
@@ -32,7 +32,9 @@ func apps() cli.Command {
|
||||
}
|
||||
|
||||
func (a *appsCmd) list(c *cli.Context) error {
|
||||
resetBasePath(&a.Configuration)
|
||||
if err := resetBasePath(&a.Configuration); err != nil {
|
||||
return fmt.Errorf("error setting endpoint: %v", err)
|
||||
}
|
||||
|
||||
wrapper, _, err := a.AppsGet()
|
||||
if err != nil {
|
||||
@@ -56,7 +58,9 @@ func (a *appsCmd) create(c *cli.Context) error {
|
||||
return errors.New("error: app creating takes one argument, an app name")
|
||||
}
|
||||
|
||||
resetBasePath(&a.Configuration)
|
||||
if err := resetBasePath(&a.Configuration); err != nil {
|
||||
return fmt.Errorf("error setting endpoint: %v", err)
|
||||
}
|
||||
|
||||
appName := c.Args().Get(0)
|
||||
body := functions.AppWrapper{App: functions.App{Name: appName}}
|
||||
|
||||
@@ -30,29 +30,25 @@ func main() {
|
||||
app.Run(os.Args)
|
||||
}
|
||||
|
||||
func resetBasePath(c *functions.Configuration) {
|
||||
var u url.URL
|
||||
u.Scheme = c.Scheme
|
||||
u.Host = c.Host
|
||||
func resetBasePath(c *functions.Configuration) error {
|
||||
u, err := url.Parse(c.Host)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
u.Path = "/v1"
|
||||
c.BasePath = u.String()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func confFlags(c *functions.Configuration) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "host",
|
||||
Usage: "raw host path to functions api, e.g. functions.iron.io",
|
||||
Name: "endpoint",
|
||||
Usage: "url to functions api endpoint e.g. http://functions.iron.io",
|
||||
Destination: &c.Host,
|
||||
EnvVar: "HOST",
|
||||
Value: "localhost:8080",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "scheme",
|
||||
Usage: "http/https",
|
||||
Destination: &c.Scheme,
|
||||
EnvVar: "SCHEME",
|
||||
Value: "http",
|
||||
Value: "http://localhost:8080",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,9 @@ func (p publishcmd) dockerpush(image string) error {
|
||||
}
|
||||
|
||||
func (p *publishcmd) route(path string, ff *funcfile) error {
|
||||
resetBasePath(&p.Configuration)
|
||||
if err := resetBasePath(&p.Configuration); err != nil {
|
||||
return fmt.Errorf("error setting endpoint: %v", err)
|
||||
}
|
||||
|
||||
an, r := extractAppNameRoute(path)
|
||||
if ff.App == nil {
|
||||
|
||||
@@ -73,7 +73,9 @@ func (a *routesCmd) list(c *cli.Context) error {
|
||||
return errors.New("error: routes listing takes one argument, an app name")
|
||||
}
|
||||
|
||||
resetBasePath(&a.Configuration)
|
||||
if err := resetBasePath(&a.Configuration); err != nil {
|
||||
return fmt.Errorf("error setting endpoint: %v", err)
|
||||
}
|
||||
|
||||
appName := c.Args().Get(0)
|
||||
wrapper, _, err := a.AppsAppRoutesGet(appName)
|
||||
@@ -107,7 +109,9 @@ func (a *routesCmd) call(c *cli.Context) error {
|
||||
return errors.New("error: routes listing takes three arguments: an app name and a route")
|
||||
}
|
||||
|
||||
resetBasePath(&a.Configuration)
|
||||
if err := resetBasePath(&a.Configuration); err != nil {
|
||||
return fmt.Errorf("error setting endpoint: %v", err)
|
||||
}
|
||||
|
||||
baseURL, err := url.Parse(a.Configuration.BasePath)
|
||||
if err != nil {
|
||||
@@ -160,7 +164,9 @@ func (a *routesCmd) create(c *cli.Context) error {
|
||||
return errors.New("error: routes listing takes three arguments: an app name, a route path and an image")
|
||||
}
|
||||
|
||||
resetBasePath(&a.Configuration)
|
||||
if err := resetBasePath(&a.Configuration); err != nil {
|
||||
return fmt.Errorf("error setting endpoint: %v", err)
|
||||
}
|
||||
|
||||
appName := c.Args().Get(0)
|
||||
route := c.Args().Get(1)
|
||||
@@ -189,7 +195,9 @@ func (a *routesCmd) delete(c *cli.Context) error {
|
||||
return errors.New("error: routes listing takes three arguments: an app name and a path")
|
||||
}
|
||||
|
||||
resetBasePath(&a.Configuration)
|
||||
if err := resetBasePath(&a.Configuration); err != nil {
|
||||
return fmt.Errorf("error setting endpoint: %v", err)
|
||||
}
|
||||
|
||||
appName := c.Args().Get(0)
|
||||
route := c.Args().Get(1)
|
||||
|
||||
Reference in New Issue
Block a user