mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Update cli to use put for deploy
This commit is contained in:
@@ -11,9 +11,9 @@ import (
|
||||
"time"
|
||||
|
||||
functions "github.com/funcy/functions_go"
|
||||
client "gitlab-odx.oracle.com/odx/functions/fn/client"
|
||||
"github.com/funcy/functions_go/models"
|
||||
"github.com/urfave/cli"
|
||||
client "gitlab-odx.oracle.com/odx/functions/fn/client"
|
||||
)
|
||||
|
||||
func deploy() cli.Command {
|
||||
@@ -156,7 +156,7 @@ func (p *deploycmd) route(c *cli.Context, ff *funcfile) error {
|
||||
if err := routeWithFuncFile(c, ff, rt); err != nil {
|
||||
return fmt.Errorf("error getting route with funcfile: %s", err)
|
||||
}
|
||||
return routesCmd.patchRoute(c, p.appName, ff.Path, rt)
|
||||
return routesCmd.putRoute(c, p.appName, ff.Path, rt)
|
||||
}
|
||||
|
||||
func expandEnvConfig(configs map[string]string) map[string]string {
|
||||
|
||||
21
fn/routes.go
21
fn/routes.go
@@ -12,11 +12,11 @@ import (
|
||||
"text/tabwriter"
|
||||
|
||||
fnclient "github.com/funcy/functions_go/client"
|
||||
client "gitlab-odx.oracle.com/odx/functions/fn/client"
|
||||
apiroutes "github.com/funcy/functions_go/client/routes"
|
||||
fnmodels "github.com/funcy/functions_go/models"
|
||||
"github.com/jmoiron/jsonq"
|
||||
"github.com/urfave/cli"
|
||||
client "gitlab-odx.oracle.com/odx/functions/fn/client"
|
||||
)
|
||||
|
||||
type routesCmd struct {
|
||||
@@ -337,6 +337,25 @@ func (a *routesCmd) patchRoute(c *cli.Context, appName, routePath string, r *fnm
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *routesCmd) putRoute(c *cli.Context, appName, routePath string, r *fnmodels.Route) error {
|
||||
_, err := a.client.Routes.PutAppsAppRoutesRoute(&apiroutes.PutAppsAppRoutesRouteParams{
|
||||
Context: context.Background(),
|
||||
App: appName,
|
||||
Route: routePath,
|
||||
Body: &fnmodels.RouteWrapper{Route: r},
|
||||
})
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case *apiroutes.PutAppsAppRoutesRouteBadRequest:
|
||||
return fmt.Errorf("error: %s", err.(*apiroutes.PutAppsAppRoutesRouteBadRequest).Payload.Error.Message)
|
||||
case *apiroutes.PutAppsAppRoutesRouteDefault:
|
||||
return fmt.Errorf("unexpected error: %s", err.(*apiroutes.PutAppsAppRoutesRouteDefault).Payload.Error.Message)
|
||||
}
|
||||
return fmt.Errorf("unexpected error: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *routesCmd) update(c *cli.Context) error {
|
||||
appName := c.Args().Get(0)
|
||||
route := cleanRoutePath(c.Args().Get(1))
|
||||
|
||||
Reference in New Issue
Block a user