Skip to content

Commit

Permalink
Add .Failed check to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ohai89 committed Dec 7, 2022
1 parent bff9f38 commit 9b4d241
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/generic_driver/basics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func main() {

// note that there is a convenience wrapper around send interactive in the generic driver as
// well, so you could simply do `d.SendInteractive` here rather than poking the channel directly
// remember to refer to `.Result` object in that case
interactiveOutput, err := d.Channel.SendInteractive(events)
if err != nil {
fmt.Printf("failed to send interactive input to device; error: %+v\n", err)
Expand All @@ -84,6 +85,10 @@ func main() {
fmt.Printf("failed to send command; error: %+v\n", err)
return
}
if r.Failed != nil {
fmt.Printf("response objects indicates failure: %+v\n", r.Failed)
return
}

fmt.Printf(
"sent command '%s', output received (SendCommand):\n %s\n\n\n",
Expand Down
5 changes: 5 additions & 0 deletions examples/generic_driver/custom_logging/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func main() {

return
}
if r.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", r.Failed)

return
}

fmt.Printf("got some output: %s\n\n\n", r.Result)
}
5 changes: 5 additions & 0 deletions examples/generic_driver/default_logging/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func main() {

return
}
if r.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", r.Failed)

return
}

fmt.Printf("got some output: %s\n\n\n", r.Result)
}
5 changes: 5 additions & 0 deletions examples/generic_driver/interactive_prompts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func main() {

return
}
if r.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", r.Failed)

return
}

fmt.Printf("interact response:\n%s\n", r.Result)
}
5 changes: 5 additions & 0 deletions examples/generic_driver/textfsm_integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func main() {

return
}
if r.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", r.Failed)

return
}

parsedOut, err := r.TextFsmParse(*arg)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions examples/netconf_driver/basics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func main() {

return
}
if r.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", r.Failed)

return
}

fmt.Printf("Config result: %s", r.Result)
}
10 changes: 10 additions & 0 deletions examples/network_driver/basics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ func main() {

return
}
if interactiveOutput.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", interactiveOutput.Failed)

return
}

fmt.Printf("output received (SendInteractive):\n %s\n\n\n", interactiveOutput.Result)

Expand All @@ -116,6 +121,11 @@ func main() {

return
}
if r.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", r.Failed)

return
}

fmt.Printf(
"sent command '%s', output received (SendCommand):\n %s\n\n\n",
Expand Down
10 changes: 10 additions & 0 deletions examples/network_driver/platforms/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ func main() {
if err != nil {
fmt.Printf("failed to send interactive input to device; error: %+v\n", err)
}
if interactiveOutput.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", interactiveOutput.Failed)

return
}

fmt.Printf("output received (SendInteractive):\n %s\n\n\n", interactiveOutput.Result)

Expand All @@ -94,6 +99,11 @@ func main() {
fmt.Printf("failed to send command; error: %+v\n", err)
return
}
if r.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", r.Failed)

return
}

fmt.Printf(
"sent command '%s', output received (SendCommand):\n %s\n\n\n",
Expand Down
5 changes: 5 additions & 0 deletions examples/network_driver/privilege_levels/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ func main() {

return
}
if r.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", r.Failed)

return
}

fmt.Printf("got running config: %s\n\n\n", r.Result)
}
5 changes: 5 additions & 0 deletions examples/network_driver/sending_configs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func main() {

return
}
if r.Failed != nil {
fmt.Printf("response object indicates failure: %+v\n", r.Failed)

return
}

fmt.Printf("sending configs took %f seconds", r.ElapsedTime)
}

0 comments on commit 9b4d241

Please sign in to comment.