TUN-3295: Show route command results

This commit is contained in:
Igor Postelnik
2020-09-17 15:19:47 -05:00
parent 20623255dd
commit 85d0afd3b0
5 changed files with 179 additions and 24 deletions

View File

@@ -244,10 +244,10 @@ func adhocNamedTunnel(c *cli.Context, name string) error {
}
if r, ok := routeFromFlag(c); ok {
if err := sc.route(tunnel.ID, r); err != nil {
if res, err := sc.route(tunnel.ID, r); err != nil {
sc.logger.Errorf("failed to create route, please create it manually. err: %v.", err)
} else {
sc.logger.Infof(r.SuccessSummary())
sc.logger.Infof(res.SuccessSummary())
}
}

View File

@@ -270,17 +270,13 @@ func (sc *subcommandContext) cleanupConnections(tunnelIDs []uuid.UUID) error {
return nil
}
func (sc *subcommandContext) route(tunnelID uuid.UUID, r tunnelstore.Route) error {
func (sc *subcommandContext) route(tunnelID uuid.UUID, r tunnelstore.Route) (tunnelstore.RouteResult, error) {
client, err := sc.client()
if err != nil {
return err
return nil, err
}
if err := client.RouteTunnel(tunnelID, r); err != nil {
return err
}
return nil
return client.RouteTunnel(tunnelID, r)
}
func (sc *subcommandContext) tunnelActive(name string) (*tunnelstore.Tunnel, bool, error) {

View File

@@ -438,7 +438,7 @@ func routeCommand(c *cli.Context) error {
const tunnelIDIndex = 1
routeType := c.Args().First()
var r tunnelstore.Route
var route tunnelstore.Route
var tunnelID uuid.UUID
switch routeType {
case "dns":
@@ -446,7 +446,7 @@ func routeCommand(c *cli.Context) error {
if err != nil {
return err
}
r, err = dnsRouteFromArg(c)
route, err = dnsRouteFromArg(c)
if err != nil {
return err
}
@@ -455,7 +455,7 @@ func routeCommand(c *cli.Context) error {
if err != nil {
return err
}
r, err = lbRouteFromArg(c)
route, err = lbRouteFromArg(c)
if err != nil {
return err
}
@@ -463,10 +463,12 @@ func routeCommand(c *cli.Context) error {
return cliutil.UsageError("%s is not a recognized route type. Supported route types are dns and lb", routeType)
}
if err := sc.route(tunnelID, r); err != nil {
res, err := sc.route(tunnelID, route)
if err != nil {
return err
}
sc.logger.Infof(r.SuccessSummary())
sc.logger.Infof(res.SuccessSummary())
return nil
}