mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Apply opposite logic call ID CLI flag
use --ignore-call-id flag to mute call ID call id now goes to STDERR
This commit is contained in:
@@ -33,7 +33,7 @@ type callID struct {
|
||||
Error apiErr `json:"error"`
|
||||
}
|
||||
|
||||
func CallFN(u string, content io.Reader, output io.Writer, method string, env []string, displayCallID bool) error {
|
||||
func CallFN(u string, content io.Reader, output io.Writer, method string, env []string, ignoreCallID bool) error {
|
||||
if method == "" {
|
||||
if content == nil {
|
||||
method = "GET"
|
||||
@@ -59,8 +59,8 @@ func CallFN(u string, content io.Reader, output io.Writer, method string, env []
|
||||
}
|
||||
// for sync calls
|
||||
if call_id, found := resp.Header[FN_CALL_ID]; found {
|
||||
if displayCallID {
|
||||
fmt.Fprint(output, fmt.Sprintf("Call ID: %v\n", call_id[0]))
|
||||
if !ignoreCallID {
|
||||
fmt.Fprint(os.Stderr, fmt.Sprintf("Call ID: %v\n", call_id[0]))
|
||||
}
|
||||
io.Copy(output, resp.Body)
|
||||
} else {
|
||||
@@ -73,8 +73,8 @@ func CallFN(u string, content io.Reader, output io.Writer, method string, env []
|
||||
// - error in body
|
||||
// that's why we need to check values of attributes
|
||||
if c.CallID != "" {
|
||||
if displayCallID {
|
||||
fmt.Fprint(output, fmt.Sprintf("Call ID: %v\n", c.CallID))
|
||||
if !ignoreCallID {
|
||||
fmt.Fprint(os.Stderr, fmt.Sprintf("Call ID: %v\n", c.CallID))
|
||||
}
|
||||
} else {
|
||||
fmt.Fprint(output, fmt.Sprintf("Error: %v\n", c.Error.Message))
|
||||
|
||||
@@ -62,8 +62,8 @@ var updateRouteFlags = append(routeFlags,
|
||||
|
||||
var callFnFlags = append(runflags(),
|
||||
cli.BoolFlag{
|
||||
Name: "display-call-id",
|
||||
Usage: "whether display call ID or not for sync calls",
|
||||
Name: "ignore-call-id",
|
||||
Usage: "whether display call ID or not",
|
||||
},
|
||||
)
|
||||
|
||||
@@ -207,7 +207,7 @@ func (a *routesCmd) call(c *cli.Context) error {
|
||||
u.Path = path.Join(u.Path, "r", appName, route)
|
||||
content := stdin()
|
||||
|
||||
return client.CallFN(u.String(), content, os.Stdout, c.String("method"), c.StringSlice("e"), c.BoolT("display-call-id"))
|
||||
return client.CallFN(u.String(), content, os.Stdout, c.String("method"), c.StringSlice("e"), c.Bool("ignore-call-id"))
|
||||
}
|
||||
|
||||
func routeWithFlags(c *cli.Context, rt *fnmodels.Route) {
|
||||
|
||||
Reference in New Issue
Block a user